7 15 3 CONTINUE Examples

LANSA Technical

7.15.3 CONTINUE Examples

Using CONTINUE within a BEGIN_LOOP loop

Using CONTINUE within a SELECT

Using CONTINUE within a BEGIN_LOOP loop

This example demonstrates how to use the CONTINUE command in a BEGIN_LOOP loop.

DEF_LIST   NAME(#EMPBROSWE) FIELDS(#EMPNO #SURNAME #GIVENAME #DEPTMENT)
           
BEGIN_LOOP 
REQUEST    FIELDS(#EMPNO) BROWSELIST(#EMPBROSWE)
FETCH      FIELDS(#EMPNO #SURNAME #GIVENAME #DEPTMENT) FROM_FILE(PSLMST) WITH_KEY(#EMPNO)
           
IF_STATUS  IS_NOT(*OKAY)
MESSAGE    MSGTXT('That employee could not be found!')
CONTINUE   
ENDIF      
           
ADD_ENTRY  TO_LIST(#EMPBROSWE)
END_LOOP
 

If the requested employee number is not found the message is issued and the CONTINUE command causes program control to skip the ADD_ENTRY command and return to the top of the loop at the REQUEST command.

Using CONTINUE within a SELECT

This example demonstrates how to use the CONTINUE command within a SELECT loop. Here, with the use of an additional user function key, selected records can be viewed and dropped if not required.

DEF_COND   NAME(*DROPPED) COND('#IO$KEY = ''09''')
DEF_LIST   NAME(#EMPBROWSE) FIELDS(#SECTION #EMPNO #SURNAME #GIVENAME)
DEF_LIST   NAME(#EMPSELECT) FIELDS(#SECTION #EMPNO #SURNAME #GIVENAME)
           
SELECT     FIELDS(#EMPBROWSE) FROM_FILE(PSLMST)
DISPLAY    FIELDS(#SECTION #EMPNO #SURNAME #GIVENAME) BROWSELIST(#EMPBROWSE) USER_KEYS((09 'Drop'))
CONTINUE   IF(*DROPPED)
ADD_ENTRY  TO_LIST(#EMPBROWSE)
ADD_ENTRY  TO_LIST(#EMPSELECT)
ENDSELECT  
DISPLAY BROWSELIST(#EMPSELECT)