Example: custquery.4gl (function fetch_rel_cust)
This function is called by the MENU options
next and previous in the
custmain.4gl module.
Function
fetch_rel_cust:01 FUNCTION fetch_rel_cust(p_fetch_flag)
02 DEFINE p_fetch_flag SMALLINT,
03 fetch_ok SMALLINT
04
05 MESSAGE " "
06 CALL fetch_cust(p_fetch_flag)
07 RETURNING fetch_ok
08
09 IF (fetch_ok) THEN
10 CALL display_cust()
11 ELSE
12 IF (p_fetch_flag = 1) THEN
13 MESSAGE "End of list"
14 ELSE
15 MESSAGE "Beginning of list"
16 END IF
17 END IF
18
19 END FUNCTIONNote:
- Line
01The parameter passed top_fetch_flagwill be1or-1, depending on the direction in which theSCROLL CURSORis to move. - Line
05resets theMESSAGEdisplay to blanks. - Line
06calls the functionfetch_cust, passing it the value ofp_fetch_flag. The functionfetch_custuses theSCROLL CURSORto retrieve the next row in the direction indicated, returningFALSEif there was no row found. - Lines
09and10If a row was found (thefetch_custfunction returnedTRUE) thedisplay_custfunction is called to display the row in the form. - Line
13If no rows were found and the direction is forward, indicated byp_fetch_flagof1, the cursor is past the end of the result set. - Line
15If no rows were found and the direction is backward, indicated byp_fetch_flagof-1, the cursor is prior to the beginning of the result set. - Line
19is the end of the functionfetch_rel_cust.