Introduction To CL Programming: Mike Pavlak Solutions Consultant Zend Technologies, Inc. Week Two
Introduction To CL Programming: Mike Pavlak Solutions Consultant Zend Technologies, Inc. Week Two
Survey 2...
Beta tester for V6R1 V5R4 (More new and changed) V5R3 (57 new and 147 changed) V5R2 V5R1 Don't ask
Review Week 1
CL History Command construction Parameters, keywords and values Edited Source in SEU Created first CL program
This week
Infocenter
http://www.ibm.com/systemi
Support ==>Infocenter
Text books
Complete CL Fourth edition (Complete to V5R3) CL Programming for the AS/400 (V4R5)
Email me at [email protected]
CL manual...
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp
Books
17 Volumes 9,322 pages Average per volume ==> 583 pages Bring lots of paper!
Variables...
Variables (cont.)...
V5R3 introduced 2 more... Integer *INT Unsigned Integer *UINT V5R4 introduced n more... Pointer variables *PTR Paved way to API processing...
Variables in action
Created by using the DCL command First instruction after the PGM command Last for the length of the procedure Can be passed into and out of program Used to store temporary data Begins with an & Examples
DCL VAR(&NAME) TYPE(*CHAR) LEN(20) VALUE('MIKE') DCL VAR(&INVOICE) TYPE(*INT) LEN(2) VALUE(8576112) DCL VAR(&PRICE) TYPE(*DEC) LEN(10 2) VALUE(1500.50)
Can be created via file reference Cannot be defined on the fly like RPG Used to populate command values To control program flow Great for communicating with API's Other friends:
Character Variables
Type *CHAR Max length at V5R4 is 32,767 bytes Minimum 1byte Default 32 bytes Examples
Decimal Variables
Integer Variables
Type *INT , *UINT Max length at V5R4 is 4 Minimum length is 2 (-32,768 to 32,767) Default is 4 (-2,147,483,648 to 2,147,483,647) Examples
Logical Variables
Type *LGL Max length is 1 Very much like an indicator Boolean '1'=True, '0' = False Examples
Variable Name Variable Type(*CHAR, *DEC, etc.) Length Default Value Storage type (Used for pointers) Based on pointer Defined on Variable (Think DS) Address offset (Think API)
CL Command Environment
Dependent
Independent
CL command that explicitly alters variable Key to programming in CL Can manipulate ANY variable type Parameters:
Example
CHGVAR Continued
DMPCLPGM Command...
Great for debugging Dumps current content of variables to SPLF May be declared more than once No parameters Dependent CL command
Simple mathematical functions Use algebraic order of evaluation... Use signs: +, -, *, /, etc.
Simple string functions May concatenate use: *CAT, *TCAT, *BCAT Substring: BIF %SST
QTEMP
Special library Exists only in memory Great for storing temporary objects Destroyed with job cleanup i5/OS uses it a LOT!
Error Handling
Escape message, (GSOD) Not quite, only at the job level Use Monitor Message command to control Can accept an error condition and direct flow Used heavily in professional CL programming Has 3 parameters
MONMSG
Can code specific (CPF1008) Can code group (CPD1000) Can code program level (At top of program)
Check for existence of object If the object does not exist (CPF9801) Then create it...
Homework...
Write and run some CL programs Assignment on website Will not be collected Can forward copies with question via email
Q&A