Presentation is loading. Please wait.

Presentation is loading. Please wait.

IBC233 Calling Programs Updated Summer 2007. Agenda Assignments are mandatory Assignment 2 due on July 13, 2007 Display files – lower case Display files.

Similar presentations


Presentation on theme: "IBC233 Calling Programs Updated Summer 2007. Agenda Assignments are mandatory Assignment 2 due on July 13, 2007 Display files – lower case Display files."— Presentation transcript:

1 IBC233 Calling Programs Updated Summer 2007

2 Agenda Assignments are mandatory Assignment 2 due on July 13, 2007 Display files – lower case Display files – packed date (4 bit vs 8 bit) Calling Programs Looping! Logic

3 RESERVDF RESERVATION MAINTENANCE 3/06/07 18:09:30 ABERNS WELCOME ABERNS RESERVATION NUMBER: 1000000000 TELEPHONE NUMBER: (123) 123-1234 RESERVATION NAME: ASS ADDRESS1: SDSD ADDRESS2: CITY: SDSD POSTAL CODE: M1M1M1 ARRIVAL DATE: 2007-03-01 SITE NAME: SDSD NUMBER OF NIGHTS: 2 ELECTRICAL: Y SEWER: Y WATER: N WATERFRONT: N NUMBER OF VEHICLES: 0 NUMBER OF PEOPLE: 2 *PLEASE ENTER NUMBER OF PEOPLE(GREATER THAN 0)* NUMBER OF TENTS: 2 *PLEASE ENTER NUMBER OF TENTS(GREATER THAN 0)* PETS: TOTAL COST:.00 DEPOSIT: 50 TOTAL DUE ON ARRIVAL:.00 CONSISTENT and quiet for the eye

4 Eyes FOCUS - where? RESERVDF Reservation Maintenance 3/06/07 22:16:45 Welcome ABERNS ABERNS Reservation Number: _-------------------------- * Enter Reservation Number Site Name: ---------------------------------------------- * Please fill in Site Address 1: ------------------------------------------------- * Please enter address Address 2: City: ---------------------------------------- Postal: ------- * Please enter City Telephone Number: ------------------ * Please enter postal in format: A#A#A * Please enter phone number Arrival Date: -------------- * Please enter a valid date Sewer: -- * Y / N Number of nights: * How many nights? Electrical: -- * Y / N Number of Vehicles: Water: -- * Y / N Number of People: * How many people? Waterfront: -- * Y / N Number of tents/campers: * How many campers? Pets: -------------------------------------------------- Total Cost: $ Deposit: $ ------------- Total Due on Arrival: $

5 Using “TYPE & EDITING” to get what you want TELNUM 10Y 0B 6 24TEXT('TELEPHONE NUMBER') EDTWRD('0( )& - ') or TELNUM 10N 0B 6 24TEXT('TELEPHONE NUMBER') EDTWRD('0( )& - ') DEPOSIT 7Y 2B 22 24TEXT('DEPOSIT') EDTCDE(3) Or DEPOSIT 7S 2B 22 24TEXT('DEPOSIT') EDTCDE(3)

6 Lowercase in Display Files Data is usually stored in UPPERCASE –Why? Check keyword –FunctionCHECK(LC) Lower case allowed ME Must enter FE Field exit required etc

7 OPM Call ( original program model) CALL –Parameters: PGM PARM

8 How it works When the call statement is executed: Your authority to the program object is checked Do you have access to all the resources required? Gather resources Program opened

9 ILE Call (Integrated Language Environment) CALLPRC Parameters: PRC PARM RTNVAL

10 How it works When the application is created, authority to modules is checked and entire application is bound When application is called all resources are allocated entire application is opened

11 PGM PARM(&PROGRAM &LIB &SECTION) :::::: DCL VAR(&PROGRAM) TYPE(*CHAR) LEN(10) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&SECTION) TYPE(*CHAR) LEN(1) DCLF FILE(ABERNSCBL/STLST) ::::::: :::::: RCVF Mixing variable types is possible but also very DANGEROUS Both calling and called program must be aware of the data type of each variable else the dreaded MCH1202 error might occur (switching between 8 and 4 bit mode – unpacked and packed data)

12 PGM PARM(&STUDENTNO &PASSWORD) /* receives student + number from CHKMRK command */ DCL VAR(&STUDENTNO) TYPE(*CHAR) LEN(9) DCL VAR(&PASSWORD ) TYPE(*CHAR) LEN(10) DCL VAR(&JOBUSER) TYPE(*CHAR) LEN(12)

13 /* COURSE-USERID SECTION ASGN PROF-USERID */ CALL PGM(OA0CHKALL) PARM( DB233 E A1 ABERNS) /* */ /* CALL PGM(OA0CHKALL) PARM( DB233 B A3 MCKENNA) */ PGM PARM(&CRSUSERID &SECT &LIBSUFFIX &PROF) /* PARMs: Course UserID, Section code, Asgn + Lib suffix, Prof's Userid. */ DCL VAR(&CRSUSERID) TYPE(*CHAR) LEN(5) /* course + User Id e.g. DC324 */ DCL VAR(&SECT) TYPE(*CHAR) LEN(1) /* SECTION */ DCL VAR(&LIBSUFFIX) TYPE(*CHAR) LEN(2) DCL VAR(&PROF) TYPE(*CHAR) LEN(10) DCL VAR(&USERID) TYPE(*CHAR) LEN(10) DCL VAR(&USERTXT) TYPE(*CHAR) LEN(50) CALLING CALLED

14 Advantages of OPM Don’t have to have all parts of the application done to test. Parts of the application can be changed without affecting the entire application

15 Disadvantages of OPM Integrated Language not supported

16 Advantages of ILE Integrated Language Support –Best language for the task You don’t have to pass all parameters to the program – previous values will be used

17 Disadvantages of ILE All modules must be in place to test application Version Control

18 DOWHILE Loop DCL VAR(&LGL) TYPE(*LGL) : CHECK: IF COND(*NOT &LGL) THEN(GOTO DONE) : (group of CL commands) GOTO CHECK DONE: New-style coding example: Evaluates COND at "top" of loop DOWHILE COND(&LGL) : (group of CL commands) body will be run zero or more times ENDDO

19 DOUNTIL Loop Old style coding example: DCL VAR(&LGL) TYPE(*LGL) : LOOP: : (group of CL commands) IF COND(*NOT &LGL) THEN(GOTO LOOP) New style coding example: Evaluates COND at "bottom" of loop DOUNTIL COND(&LGL) : (group of CL commands) body will be run one or more times ENDDO

20 DOFOR Loop Syntax: DOFOR VAR( ) FROM( ) TO( ) BY( ) VAR must be *INT or *UINT variable FROM and TO can be integer constants, expressions, or variables BY must be an integer constant (can be negative) defaults to '1', other parameters are required FROM/TO expressions are evaluated at loop initiation; TO evaluated after increment

21 DOFOR Loop (continued) Old-style coding example: DCL &LOOPCTL TYPE(*DEC) LEN(5 0) DCL &LOOPLMT TYPE(*DEC) LEN(5 0) : CHGVAR &LOOPCTL VALUE(1) CHECK: IF COND(&LOOPCTL *GT &LOOPLMT) THEN(GOTO DONE) : (group of CL commands) CHGVAR &LOOPCTL VALUE(&LOOPCTL+1) GOTO CHECK DONE: New-style coding example: Checks for loop exit at "top" of loop (like DOWHILE) DCL &LOOPCTL TYPE(*INT) LEN(4) DCL &LOOPLMT TYPE(*INT) LEN(4) : DOFOR VAR(&LOOPCTL) FROM(1) TO(&LOOPLMT) BY(1) : (group of CL commands) body will be run zero or more times ENDDO

22 LEAVE and ITERATE Allowed only within a DOWHILE, DOUNTIL or DOFOR group LEAVE passes control to next CL statement following loop ENDDO ITERATE passes control to end of loop and tests loop exit condition Both support CMDLBL (Command label) parameter to allow jump out of multiple (nested) loops – Both default to *CURRENT loop Example: : (group of CL commands) IF (%SST(&NAME 1 10) *EQ ‘*NONE’) THEN(LEAVE LOOP1) ELSE (DO) IF (%SST(&NAME 11 10) *EQ ‘*LIBL’) THEN(ITERATE) ENDDO : (group of CL commands)

23 SELECT Group SELECT starts a “condition” group ENDSELECT ends group Group must have at least one WHEN – WHEN command has COND and THEN parameters (like IF) OTHERWISE (optional) run if no WHEN COND = True – OTHERWISE command has only CMD parameter (like ELSE) Example: SELECT WHEN COND(&TYPE *EQ *CMD) THEN(DO) : …..(group of CL commands) ENDDO WHEN COND(&TYPE *EQ *PGM) THEN(DO) : ……(group of CL commands) ENDDO ….. OTHERWISE CMD(CHGVAR &BADTYPE ‘1’) ENDSELECT

24 Enhanced File Support Will support up to 5 file "instances" using DCLF Instances can be for the same or different files New OPNID (Open identifier) parameter added to DCLF statement Default for OPNID is *NONE –Only one DCLF allowed with OPNID(*NONE) OPNID accepts simple name, up to 10 characters

25 Enhanced File Support (continued) If OPNID specified, declared CL variables are prefixed by this name and an underscore (e.g. &MYTESTFILE_CUSTNAME ) OPNID added to existing file I/O CL commands – RCVF –ENDRCV – SNDF –SNDRCVF – WAIT

26 File / variables Identifier qualification DCLF FILE(STUDENTS) OPNID(STPF) DCLF FILE(STUDDF) OPNID(DSPF) DCL &EOF *LGL 1 ::::::: CHGVAR &EOF '0' RCVF OPNID(STPF) DOWHILE (*NOT &DSPF-IN03) : ::::: CHGVAR &DSPF-FINESOWED &STPF-FINESOWED IF COND(&DSPF-FEESOWED *GT &STPF-FEESOWED) + THEN(CHGVAR &DSPF-IN30 '1') IF COND(&DSPF-FINESOWED *NE &STPF-FINESOWED) + THEN(CHGVAR &DSPF-IN31 '1') : ::::: SNDRCVF OPNID(DSPF) RCVF OPNID(STPF)

27 PGM DCLF FILE(RADIO) RCDFMT(PROMPT) DCL VAR(&LEN) TYPE(*DEC) LEN(2) DCL VAR(&OPTION) TYPE(*CHAR) LEN(50) DCL VAR(&DIV) TYPE(*CHAR) LEN(10) : CALLPRC PRC(ASSIGN2B) PARM(&DIV &OPTION) Called program receiving passed parameters PGM PARM(&DIVI &OPTI) DCL VAR(&DIVI) TYPE(*CHAR) LEN(10) DCL VAR(&OPTI) TYPE(*CHAR) LEN(50) IF (&DIVI *EQ 'DIVISION2') THEN(DO) OVRDBF FILE(INFILE) TOFILE(QGPL/CHAP8AS2) + MBR(DIVISION2) POSITION(*START) SHARE(*YES) ENDDO OPNQRYF FILE((INFILE)) QRYSLT(&OPTI) + KEYFLD((EMPNO)) CPYFRMQRYF FROMOPNID(INFILE) TOFILE(QTEMP/CHAP8AS2) + MBROPT(*REPLACE) CRTFILE(*YES) And passing it further down the line to another program / utility or tool

28 Passing parameters "by value" CALLPRC (Call Procedure) command supports calls from ILE CL procedures to other ILE procedures In prior releases, CALLPRC only supported passing parameters "by reference" Can specify *BYREF or *BYVAL special value for each parameter being passed Enables ILE CL to call many MI and C functions and other procedure APIs Maximum numbers of parameters 300


Download ppt "IBC233 Calling Programs Updated Summer 2007. Agenda Assignments are mandatory Assignment 2 due on July 13, 2007 Display files – lower case Display files."

Similar presentations


Ads by Google