Example 1: Use the BEGIN_LOOP / END_LOOP commands to insert records into a file until the user uses the EXIT or menu function key:
GROUP_BY NAME(#CUSTOMER) FIELDS(#CUSTNO #NAME #ADDL1 #ADDL2 #ADDL3)
BEGIN_LOOP
REQUEST FIELDS(#CUSTOMER) EXIT_KEY(*YES *EXIT) MENU_KEY(*YES *MENU)
INSERT FIELDS(#CUSTOMER) TO_FILE(CUSMST) VAL_ERROR(*LASTDIS)
CHANGE FIELD(#CUSTOMER) TO(*DEFAULT)
END_LOOP
Example 2: Use the BEGIN_LOOP / END_LOOP commands to reference entries 1 through 10 of a working list called #LIST:
BEGIN_LOOP USING(#I) FROM(1) TO(10)
GET_ENTRY NUMBER(#I) FROM_LIST(#LIST)
END_LOOP
Example 3: Use the BEGIN_LOOP / END_LOOP commands to reference entries 10 through 1 (i.e.: backwards) of a working list called #LIST:
BEGIN_LOOP USING(#I) FROM(10) TO(1) STEP(-1)
GET_ENTRY NUMBER(#I) FROM_LIST(#LIST)
END_LOOP
Example 4: Use the BEGIN_LOOP / END_LOOP commands to reference even numbered entries between 1 and 100 in a working list called #LISTF:
BEGIN_LOOP USING(#I) FROM(2) TO(100) STEP(2)
GET_ENTRY NUMBER(#I) FROM_LIST(#LIST)
END_LOOP
Example 5: Use the BEGIN_LOOP / END_LOOP commands to reference odd numbered entries between 1 and 100 in a working list called #LIST:
BEGIN_LOOP USING(#I) FROM(1) TO(99) STEP(2)
GET_ENTRY NUMBER(#I) FROM_LIST(#LIST)
END_LOOP