Documente Academic
Documente Profesional
Documente Cultură
Part 9
IF (&user = 'STUDENT1') +
IF (&number = 5) DSPTAP TAP01 OUTPUT(*PRINT)
IF (&user = 'STUDENT1') +
IF (&number = 5) +
IF (&day = 'Tuesday') DSPTAP TAP01 OUTPUT(*PRINT)
ELSE Command
SELECT
WHEN (&sales *LE 5000) /* Do nothing */
WHEN (&sales *LE 10000) CALL PGM1
WHEN (&sales *LE 20000) CALL PGM2
OTHERWISE CALL PGM3
ENDSELECT
SELECT
WHEN (&int *LT 0) /* Do nothing */
WHEN (&int *EQ 0) DO
CHGVAR &status Y
CALL PGMYES
DLTF TRANSFILE
ENDDO
OTHERWISE CALL PGM2
ENDSELECT
Program Looping and Iteration
SUBR CLEANUP
DLTF WORKFILE
CALL PGMLOG
ENDSUBR
SUBR NO
CALL PGMNO
CALL RESET
IF (&continue = 'N') CHGVAR &option 0
ELSE CHGVAR &option 1
ENDSUBR
SUBR YES
CALL PGMYES
DLTF TRANSFILE
IF (&continue = 'N') CHGVAR &option 0
ELSE CHGVAR &option 1
ENDSUBR
Subroutines and GOTO
ENDSUBR
Control returns to line immediately following
CALLSUBR
Only one ENDSUBR allowed per subroutine
RTNSUBR
Leaves a subroutine early
Subroutine can have several RTNSUBR commands
SUBR MYSUBR
CALL PGMYES
IF (&cancel = 'Y') RTNSUBR
DLTF TRANSFILE
IF (&continue = 'N') CHGVAR &option 0
ELSE CHGVAR &option 1
ENDSUBR
Using a Return Value