CL Programming Review
-
Upload
raven-booth -
Category
Documents
-
view
16 -
download
0
description
Transcript of CL Programming Review
![Page 1: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/1.jpg)
CL PROGRAMMING REVIEWDBT544
Database for DB2/400
![Page 2: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/2.jpg)
CL RESTRICTIONS
Only open 5 files Cannot update files Only 25 levels of nested iteration and
selection statements Cannot create reports – only execute them
![Page 3: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/3.jpg)
BEGIN AND END
PGM Also used to include parameters passed to the
program
ENDPGM Last statement executed and control returns to
the calling program
![Page 4: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/4.jpg)
DECLARING VARIABLES Declaring files (DCLF)
Specify the file name If more than one file used in the program than
specify the opnid Limit of 5 files open in the program
Declaring variables (DCL) *DEC, *CHAR, *LGL, *INT, *UINT Date, Time, and Timestamp variables are treated
as *CHAR
![Page 5: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/5.jpg)
DEFINING A LOGICAL BLOCK
Do
Enddo
Can be embedded in iteration, and selection statements
![Page 6: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/6.jpg)
ITERATION
Dowhile (condition)
Enddo
Tests the condition first. If the condition is true, then the logic block is executed.
![Page 7: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/7.jpg)
ITERATION
Dountil (condition)
Enddo
Tests the condition after the logic block is executed
In other words, the logic block is always executed at least once.
![Page 8: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/8.jpg)
ITERATION
DOFOR &variable &from &to &by
ENDO
Executes the loop by checking the contents of &variable. &variable starts the the &from value. The loop ends when &variable reaches the &to value. &variable is incremented by the &by variable. If &by is left out then &variable is incremented by 1.
![Page 9: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/9.jpg)
SELECTION
If (condition)
Else
End-if.
Allows execution of code based on a condition. If the condition is false, then the else logic is executed.
If statements process only one CL command if true and one CL command if false
Often used in combination with the DO ENDDO logic block.
![Page 10: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/10.jpg)
SELECTION
SelectWhen cond(condition 1) then(cl command)
When cond(condition 2) then(cl command)Otherwise (cl command)
Endselect
Executes the first true condition and then exits the structure
![Page 11: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/11.jpg)
WORKING WITH FILES RCVF OPNID(openidname)
Reads records from a file Works with database files and display files
SNDF OPNID(openidname) Writes to a file Works only with display files
SNDRCVF OPNID(openidname) Reads a record from a file Writes to a file Works only with display files
OPNID only needed if more than one file is opened in the program
![Page 12: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/12.jpg)
MONITORING FOR MESSAGES
MONMSG MSGID(CPF9999) EXEC(cl command)
Used to trap error messages Used to avoid the Black Screen of Death
![Page 13: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/13.jpg)
INDICATORS
Used in display file to pass information between the program and the display file.
Two types of indicators Response (ie function keys) Option (ie reverse image)
![Page 14: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/14.jpg)
HAPPY BIRTHDAY PROGRAMWrite an interactive program that prompts for a userid and sends a happy birthday greeting to that user. Program should terminate when F3 is pressed
![Page 15: CL Programming Review](https://reader036.fdocuments.in/reader036/viewer/2022062408/56813654550346895d9dda2b/html5/thumbnails/15.jpg)
CL COMMANDS FOR THE LAB
RUNSQLSTM DSPOBJD DSPFD DSPDBR DSPOBJAUT RTVJOBA DSPSPLF