KLSZPINB - Part 4
The EPILOGUE section of KLSZPINB processes the user's entries in
the BODY section. Depending on the action code or function key selected
by the user, the EPILOGUE invokes another dialog:
- KLSZPINC to add a record
- KLSZPIND to edit a record
- KLSZPINE to delete a record
The first part of the EPILOGUE is shown in Figure 1 . An explanation follows the figure.
)epilogue
if &syskey = 'ENTER' do
call Get_Select /* Process selected rows first*/
call Re_Position /* Set top row of table disply*/
end
else if &syskey = 'PF3' /* Exit requested? */
return /* Yes, return to caller */
else if &syskey = 'PF5' do /* Add new inventory record? */
dialog KLSZPINC /* Call inventory add dialog */
call Re_Position /* Set top row of table disply*/
end
else if &syskey = 'PF7' do /* Backward scroll requested? */
if &f7 = '**' /* Is bkwd disabled? */
call badkey /* Yes, beep at user */
else do /* No, scroll 1 scr back */
call Get_Select /* Process selected rows first*/
call Re_Position /* Set top row of table disply*/
tbskip(&PCItblH (neg (&ZTBsize-1)))
end
end
else if &syskey = 'PF8' do /* Forward Scroll requested */
if &f8 = '**' /* Is Fwd disabled? */
call badkey /* Yes, beep at user */
else do /* No, scroll 1 scr fwd */
call Get_Select /* Process selected rows first*/
call Re_Position /* Set top row of table disply*/
tbskip(&PCItblH (&ZTBsize-1))
end
end
else
call badkey /* Invalid key pressed */
reshow
/*
* bad key routine
*/
badkey:
set errmsg '&syskey is not active' /* Set error message */
dialog KLSZPERR '&errmsg' /* Call error msg dialog */
return /* Return to caller */
- )epilogue
- The EPILOGUE processes the input from the BODY section. It uses IF...ELSE statements to check the contents of SYSKEY, the predefined variable that contains the value of the last attention key pressed, to determine the action that the user requested.
- if...else
- The IF...ELSE statement tests the truth of a condition and initiates
an action based on the result of the test. The five IF...ELSE statements
in the first part of the EPILOGUE test for the last attention key
pressed.
- &syskey = 'ENTER'
- If SYSKEY contains ENTER, the user pressed the Enter key. The DO...END statement is executed when the condition is true.
- do...end
- The DO...END statement associated with each IF statement is executed when the condition tested is true. When the condition is false, control passes to the subsequent ELSE statement.
- call Get_Select
- The CALL statement branches to the label GET_SELECT, a subroutine that apears later in the EPILOGUE. GET_SELECT invokes the dialogs that handle editing and deleting a record in the table. When GET_SELECT completes processing, control returns to the statement following the CALL statement, CALL RE_POSITION.
- call Re_Position
- The CALL statement branches to the label RE_POSITION, a subroutine that appears later in the EPILOGUE. It repositions the cursor after a record is added to the table or after all rows are processed. When RE_POSITION completes, control returns to the statement following the CALL to the RE_POSITION. Control branches to the RESHOW statement when SYSKEY equals ENTER.
- if &syskey = 'PF3'
- When SYSKEY does not contain ENTER, control branches to this IF statement, which checks if the user pressed F3 to log off.
- return
- If SYSKEY contains PF3, the RETURN statement is executed and control of the dialog is returned to KLSZPTRK, where the logoff occurs.
- if &syskey = 'PF5'
- This IF statement is executed when SYSKEY does not contain Enter or PF3. It tests for PF5 which indicates that the user wants to add a record to the table. The statements enclosed between DO and END are executed when SYSKEY contains PF5.
- dialog KLSZPINC
- The DIALOG statement calls KLSZPINC, the dialog that adds a record to the table. KLSZPINC is described in Managing a Table.
- call Re_Position
- After KLSZPINC completes processing, control returns to this statement. The CALL statement branches to the label RE_POSITION, a subroutine that appears later in the EPILOGUE.
- if &syskey = 'PF7'
- If SYSKEY does not contain Enter, PF3, or PF5, control branches to this ELSE statement where the value of SYSKEY is tested again. The IF statement checks to see if the user pressed F7 to select backward scrolling. The DO...END statement is executed when SYSKEY contains F7.
- if &f7 = '**'
- This IF statement checks the contents of the variable F7 for two asterisks (**), which means that backward scrolling is not available. When this IF statement is true, the next statement is executed.
- call badkey
- The CALL statement branches to the label BADKEY when forward scrolling is requested and the forward scrolling key is disabled. BADKEY is a subroutine that appears later in the EPILOGUE. It creates an error message and invokes KLSZPERR, the error handling dialog.
- call Get_Select
- The CALL statement branches to the label GET_SELECT, a subroutine that appears later in the EPILOGUE. See the description of GET_SELECT that appears earlier in this section.
- call Re_Position
- The CALL statement branches to the label RE_POSITION, a subroutine that appears later in the EPILOGUE. See the call to RE_POSITION earlier in this section for a description.
- tbskip
- TBSKIP is a table function that scrolls backward and forward through
a table by moving the CRP a specified number of rows.
- &PCItblH
- This variable contains the handle of the table that is being acted upon by TBSKIP.
- neg (&ZTBsize-1)
- This formula specifies the number of rows to scroll. NEG is an arithmetic operator that makes an arithmetic value negative. ZTBSIZE is a predefined variable that contains the number of rows in the previous display. This formula causes the table to scroll backward one row short of a full panel display.
- if &syskey = 'PF8'
- If SYSKEY does not equal Enter, PF3, PF5, or PF7, this IF statement is executed to check for PF8, indicating that the user requested forward scrolling. The DO...END statement is executed when SYSKEY equals PF8.
- if &f8 = '**'
- This IF statement checks the contents of the variable F8. If F8 contains two asterisks (**), no rows are available for forward scrolling and the request is invalid. The next statement is executed.
- call badkey
- The CALL statement branches to the label BADKEY, a subroutine that appears later in the EPILOGUE section. See the earlier call to BADKEY for a description of the subroutine.
- call Get_Select
- The CALL statement branches to label GET_SELECT, a subroutine that appears later in the EPILOGUE. See the earlier call to GET_SELECT for a description of the subroutine.
- call Re_Position
- The CALL statement branches to the label, RE_POSITION, a subroutine that appears later in the EPILOGUE. See the earlier call to RE_POSITION for a description of the subroutine.
- tbskip
- This TBSKIP scrolls forward through the table according to the
formula enclosed in parentheses.
- (&ZTBsize-1)
- This formula specifies the number of rows to scroll. ZTBSIZE is a predefined variable that contains the number of rows in the previous display. This formula causes the table to scroll forward one row short of a full panel display.
- call badkey
- The CALL statement branches to the label BADKEY, a subroutine that appears later in the EPILOGUE, if SYSKEY contained none of the keys tested in the IF statements, indicating that an invalid key was pressed.
- reshow
- When BADKEY completes execution, control is returned to the RESHOW statement, which causes the dialog to re-execute from the PROLOGUE section. RESHOW is also executed after all IF...ELSE statements.
- badkey:
- The subroutine label, BADKEY, begins the subroutine.