Search | Synergex.com | Contact Us | Resource Center Login | Home|
News
If id and row are both integers, what is displayed on the first visible row of the window named "X" at the end of the following code snippet?    
w_proc(WP_CREATE, id, "X", 20, 10, WP_PLACE, id, 1, 1)
for row from 1 thru 100
     w_disp(id, WD_POS, row, 1, %string(row)) 
w_area(id,  WA_SET, 20, 1, 5, 10) 
w_updt 

a. "1"

b. "16"

c. "20"

d. "100"

e. a runtime error occurs

 

In this example, we create a window that has 20 rows by 10 columns, and we place it on the screen.  We then use a loop to display the row number on each row.  Our loop runs to 100 instead of 20, but this does not produce an error (e), because the Synergy Windowing API limits the WD_POS operation to valid coordinates.  Thus, 21 through 100 simply overwrite row 20.

 

Next, we attempt to set the processing area of the window to five rows beginning at row 20.  This also does not produce an error, but rather limits the coordinates.  The origin has priority over the height, so instead of setting the area to five rows beginning at 16 (b), we get one row beginning at 20 (c), which contains "100" (d, see the previous paragraph).

 

However, this call to W_AREA only sets the processing area, not the display area.  If we wanted to affect the display area, we would need to add ", WA_COPY, WAC_PTOD" to the argument list.  As the code currently stands, the display area remains at all 20 rows, so the first row contains "1".  Thus, (a) is the correct answer.

 

The separation of the concepts of processing area and display area allow you to make modifications to large sections of windows without affecting what portion of the window is currently visible to the user.  The processing area is only a logical sub-window for further operations via W_AREA.  Thus, whenever you set or change the processing area, be sure to ask yourself, "Now, what am I doing with it?"