Example: custquery.4gl (function fetch_rel_cust)
This function fetches a customer record in the direction specified by the flag passed as parameter.
Function
fetch_rel_cust: 1 FUNCTION fetch_rel_cust(p_fetch_flag SMALLINT) RETURNS ()
2 MESSAGE " "
3 IF fetch_cust(p_fetch_flag) THEN
4 CALL display_cust()
5 ELSE
6 IF p_fetch_flag == 1 THEN
7 MESSAGE "End of list"
8 ELSE
9 MESSAGE "Beginning of list"
10 END IF
11 END IF
12 END FUNCTIONNote:
- Line
1: The parameter passed top_fetch_flagwill be1or-1, depending on the direction in which the scroll cursor is to move. The function returns no value. - Line
2resets the message display to blanks. - Line
3calls the functionfetch_cust, passing it the value ofp_fetch_flag. The functionfetch_custreturningFALSEif there was no row found. - Line
4If a row was found (thefetch_custfunction returnedTRUE), thedisplay_custfunction is called to display the row in the form. - Line
6If no rows were found and the direction is forward, indicated byp_fetch_flagof1, the cursor is past the end of the result set. - Line
8If 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.