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 SMALLINT) RETURNS ()
02 DEFINE fetch_ok BOOLEAN
03
04 MESSAGE " "
05 IF (fetch_ok := fetch_cust(p_fetch_flag) ) THEN
06 CALL display_cust()
07 ELSE
08 IF (p_fetch_flag = 1) THEN
09 MESSAGE "End of list"
10 ELSE
11 MESSAGE "Beginning of list"
12 END IF
13 END IF
14
15 END FUNCTIONNote:
- Line
01The parameter passed top_fetch_flagwill be1or-1, depending on the direction in which theSCROLL CURSORis to move. - Line
04resets theMESSAGEdisplay to blanks. - Line
05calls 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. - Line
06If a row was found (thefetch_custfunction returnedTRUE), thedisplay_custfunction is called to display the row in the form. - Line
09If no rows were found and the direction is forward, indicated byp_fetch_flagof1, the cursor is past the end of the result set. - Line
11If 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
15is the end of the functionfetch_rel_cust.