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

Slides:



Advertisements
Similar presentations
ICE1341 Programming Languages Spring 2005 Lecture #13 Lecture #13 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Advertisements

Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
CL programming (with Display Files). Review Display Files Constants Input/Output fields Attributes Activating Function keys.
Advanced RPG Chapter 8 Interactive Applicatons. Interactive Applications  Batch Processing: Program is run without human intervention or control.  Interactive.
Programming with Microsoft Visual Basic th Edition
1 Kevin Forsythe DMC Consulting What’s New In CL Programming.
Programming Logic and Design Fourth Edition, Introductory
1 CIS Jan Overview Selection Statements –If Statement –Else –Nested If-Else –Switch Repetition Statements –While statement –For Statement.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
CONTROL STATEMENTS Lakhbir Singh(Lect.IT) S.R.S.G.P.C.G. Ludhiana.
UNIT II Decision Making And Branching Decision Making And Looping
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
Chapter 5: Control Structures II (Repetition)
CHAPTER 5: CONTROL STRUCTURES II INSTRUCTOR: MOHAMMAD MOJADDAM.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Chapter 4 Program Control Statements
Fundamentals of C and C++ Programming Control Structures and Functions.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Programming Logic and Design Fifth Edition, Comprehensive
Set path vs current schema. Set Current Schema ‘The CURRENT SCHEMA special register specifies a VARCHAR(128) value that identifies the schema name used.
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Stored Procedure James Wang.
Additional Control Structures. Chapter 9 Topics Switch Statement for Multi-way Branching Do-While Statement for Looping For Statement for Looping Using.
CPS120: Introduction to Computer Science Decision Making in Programs.
‘Tirgul’ # 3 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #3.
1 Chapter 9 Additional Control Structures Dale/Weems.
1 Additional Control Structures. 2 Chapter 9 Topics  Switch Statement for Multi-way Branching  Do-While Statement for Looping  For Statement for Looping.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
Chapter 3. Outline Relational Operators Loops Decisions Logical Operators Precedence Summary.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Chapter 05 (Part III) Control Statements: Part II.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
IBC233 Lecture 2 Updated Winter 2008 Agenda Test next Week – Jan 23 ISeries Architecture CL (Control Language) Library Lists Operations Navigator.
Week 4 presentation! This week we will cover editing and the use of the on-board tools provided, SEU and PDM.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 5A Repetition (Concepts)
JavaScript, Fourth Edition
CSC 212 Object-Oriented Programming and Java Part 2.
Java™ How to Program, Early Objects Version, 8/e © by Pearson Education, Inc. All Rights Reserved.
Computer Science By: Erica Ligons Compound Statement A compound statement- block A compound statement- is a unit of code consisting of zero or more statement.
Sections © Copyright by Pearson Education, Inc. All Rights Reserved.
Loops cause a section of a program to be repeated a certain number of times. The repetition continues while a condition remains true. When a condition.
1 Standard Version of Starting Out with C++, 4th Brief Edition Chapter 5 Looping.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
1 Programming in C++ Dale/Weems/Headington Chapter 9 Additional Control Structures (Switch, Do..While, For statements)
Lecture 7: Menus and getting input. switch Multiple-selection Statement switch Useful when a variable or expression is tested for all the values it can.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
1 Week # 5 Agenda CL Programming CL Commands Job Logs Review for test # 1.
Learning Javascript From Mr Saem
Chapter 10 Programming Fundamentals with JavaScript
Creating professional PDF documents from basic Spool Files, utilising report definitions, maps and dynamic use of images. (CVTSPLDBF & CVTSPLPDF)
JavaScript: Control Statements I
Chapter 10 Programming Fundamentals with JavaScript
- Additional C Statements
Week 4 Updated Winter 2011.
Chapter 7 Additional Control Structures
Program Control Topics While loop For loop Switch statement
2.6 The if/else Selection Structure
Chapter 5: Control Structures II (Repetition)
Dale Roberts, Lecturer IUPUI
Programming Languages and Paradigms
21st-Century CL Ted Holt Senior Software Developer, Profound Logic Software Senior Technical Editor, The Four Hundred
What’s New In CL Programming
CL programming (with Display Files)
Presentation transcript:

IBC233 Calling Programs Updated Summer 2007

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

RESERVDF RESERVATION MAINTENANCE 3/06/07 18:09:30 ABERNS WELCOME ABERNS RESERVATION NUMBER: TELEPHONE NUMBER: (123) RESERVATION NAME: ASS ADDRESS1: SDSD ADDRESS2: CITY: SDSD POSTAL CODE: M1M1M1 ARRIVAL DATE: 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

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: $

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)

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

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

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

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

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

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)

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)

/* 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

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

Disadvantages of OPM Integrated Language not supported

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

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

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

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

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

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

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)

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

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

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

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)

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

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