CALL Statement
The CALL statement invokes an external subprogram. Usually, the
CALLed program is an existing program in another language that performs an
unsupported function. 
CALL program-name [NR] USING ( field-name … ) 
MOVE Statement
You use the MOVE statement to transfer data from one location to
another. MOVE is useful for moving data without conversion and for moving character
strings with variable lengths. 
- You can move a field or a
     literal to a field or move a file to a file.
 - A sending field longer than
     a receiving field is truncated on the right.
 - A longer receiving field is
     padded on the right with spaces or an alternate fill character.
 - Spaces or zeroes can be
     moved to one or many fields.
 
MOVE NAME 20 TO HOLD-NAME 
MOVE NAME CTR TO HOLD-NAME FILL ‘*’
MOVE SPACES TO NAME, HOLD-NAME, HOLD-DIV
MOVE LIKE file-name-1 TO file-name-2
MOVE NAME CTR TO HOLD-NAME FILL ‘*’
MOVE SPACES TO NAME, HOLD-NAME, HOLD-DIV
MOVE LIKE file-name-1 TO file-name-2
MOVE LIKE
MOVE LIKE moves the value of fields with identical names from one
file to another while converting numeric data-types from one format to another.
- The rules for the assignment
     statement also apply to MOVE LIKE.
 - Because the same field-name
     can be used in more than one file, you must qualify duplicate field-names
     by prefixing the field-name with the file-name and a colon.
 
User Procedures (PROCs) 
A user PROC is a group of user-written EASYTRIEVE PLUS statements
designed to accomplish a task. You use a user PROC when identical logic is needed
in several places in the activity. 
A user PROC must be invoked in the activity with a PERFORM
statement. 
PERFORM proc-name
proc-name. PROC
** Logic **
END-PROC
proc-name. PROC
** Logic **
END-PROC
Proc-name 
Proc-name is the same name as in the PERFORM statement and is followed by a period, a space, and the keyword PROC.
END-PROC
Every PROC must have an END-PROC. At END-PROC, control returned to the statement following the PERFORM statement that invoked the PROC
START / FINISH parameters
You use the optional START and FINISH parameters of the JOB statement to automatically incorporate procedures into processing activities.
JOB input file-name [ NAME job-name ] + [ START proc-name ]
[FINISH proc-name] 
START parameter
You use START to identify a procedure to be executed during initiation of the JOB activity.
- The procedure is invoked
     automatically after the file are opened and prior to the first input
     record.
 - A typical START procedure
     might initialize working storage fields or establish a position in a keyed
     sequenced file.
 
FINISH parameter 
You use FINISH to identify a procedure to be executed during the normal termination of the JOB activity.
- The procedure is invoked
     after the last input record is processed and before the files are closed.
 - A typical FINISH procedure
     displays control information accumulated during execution of the JOB
     activity.
 - A FINISH proc is invoked if
     a STOP is encountered but it is not invoked if a STOP EXECUTE is
     encountered.
 
GOTO Statement
You use the GOTO statement to modify the natural top-to-bottom logic flow in a program.
GOTO JOB transfers control to the top of current JOB activity.
Example 
JOB INPUT PERSNL NAME DIV-LIST
IF DIV = ‘A’
----> GOTO JOB
END-IF
IF DIV = ‘B’
----> GOTO CHECK-REG-RTN
END-IF
** Logic **
CHECK-REG-RETURN
JOB INPUT PERSNL NAME DIV-LIST
IF DIV = ‘A’
----> GOTO JOB
END-IF
IF DIV = ‘B’
----> GOTO CHECK-REG-RTN
END-IF
** Logic **
CHECK-REG-RETURN
DO WHILE / END-DO Statements 
You use the DO WHILE and END-DO statements to provide a controlled loop for repetitive program logic.
- The logic between DO WHILE
     and END-DO is executed until the conditional expression on the DO WHILE
     statement is false.
 - Conditional expressions
     follow the rules of IF statements.
 
JOB INPUT PERSNL NAME DO-EX-1 
CTR = 0
DO WHILE CTR LT 10
CTR = CTR + 1
** Logic **
END-DO
IF …
CTR = 0
DO WHILE CTR LT 10
CTR = CTR + 1
** Logic **
END-DO
IF …
Nesting Example
You can nest DO WHILE statements. (The inner logic loop must be completely within the outer logic loop.)
No comments:
Post a Comment