• Keine Ergebnisse gefunden

CALLING A PROCEDURE (BEGIN COMMAND)

Im Dokument C Volume 3 (Seite 125-129)

The BEGIN command initiates execution of a procedure. When a BEGIN command is entered, the system begins executing the specified procedure and continues until a REVERT command is entered. The REVERT command causes the system to return to the command record of the calling job or procedure. The system then continues execution with the first command following the

BEGIN command. Procedures can be nested up to a level of 50 nested procedures.

Figure 4-5 shows a diagram of a procedure call from a batch job and from an interactive job.

The interactive example also diagrams a first level nested procedure call.

r

Batch Job File AJOB.

USER,USERNAME,PASSWORD.

BEGIN, APROC.

Procedure .PROC,APROC*I,

REVERT.

Interactive Command

Procedure

BEGIN,BPROC

.PROC,BPROC*I.

BEGIN,

CPROC-REVERT.

Procedure .PR0C,CPR0C*I,

REVERT.

Figure 4-5. Calling a Procedure

j & ^ ^ S .

60459680 D 4-41

/ * ^ S

You can alter the contents of a procedure by passing parameters to the procedure through the BEGIN command. The system substitutes the parameter values into the procedure body according to the rules specified in the procedure header (refer to .PROC Directive earlier in this s e c t i o n ) .

The system allows you to input the parameters from a full-screen format if the following conditions are true:

a Yo u r t e r m i n a l s u p p o r t s f u l l - s c r e e n i n p u t f o r p r o c e d u r e s .

• Your terminal is in screen mode (refer to the SCREEN command).

• The procedure is interactive; that is, the .PROC directive contains a *M or *I.

• You do not supply all the required parameters on the procedure call.

Formats:

BEGIN,pname,pfile,plfp2,...,pn.comment o r

- p n a m e , p fi l e , p j , p 2 , . . . , p n . c o m m e n t o r

pname,pi,p2,...,pn.comment o r

p f i l e , P i , p 2 p n « c o m m e n t

The first format is the full BEGIN command format that can be used in either batch or

interactive jobs. When you use this format, the system uses the following search order when a t t e m p t i n g t o l o c a t e fi l e p fi l e :

l o c a l fi l e s

indirect access files in your permanent file catalog direct access files in your permanent file catalog

indirect access files under user name LIBRARY direct access files under user name LIBRARY

The second format can be used only from an interactive job. It uses the same search order a s t h e fi r s t f o r m a t .

The third and fourth formats are the name call formats in which the command name BEGIN can be omitted.

A ^ S

4 ~ 4 2 6 0 4 5 9 6 8 0 K

The third format can be used from a batch or interactive job if one of the following is true:

• pname is a procedure within a record in a file called pname. The system locates this procedure record and executes it.

• pname is a procedure In a global library set.

• pname is a procedure in the system library.

The fourth format can be used from a batch or interactive job. pfile is the name of a local fi l e . T h e s y s t e m e x e c u t e s t h e fi r s t p r o c e d u r e o n p fi l e .

ifSP"*^

Parameter pname

p fi l e

D e s c r i p t i o n

Specifies the procedure name from the procedure header directive. If pname is omitted from the first format, two consecutive commas must be specified.

T h e d e f a u l t p r o c e d u r e i s t h e r e c o r d a t t h e c u r r e n t p o s i t i o n o f p fi l e . I f pfile is at its end-of-information, the system rewinds pfile and uses the fi r s t p r o c e d u r e o n p fi l e . I f p fi l e i s I N P U T, t h e fi l e i s n o t r e w o u n d . Specifies the name of the file containing the procedure. The file name pfile must be inserted as the second parameter in the first format. Its omission is indicated by two consecutive commas following pname. To get a description of the procedure pname, you can append a question mark to pfile ( r e f e r t o R e q u e s t i n g H e l p o n P r o c e d u r e C a l l s l a t e r i n t h i s s e c t i o n ) . F i l e pfi le is n o t a u t om atically r e tu r n e d a ft e r th e p r o ce d u r e e x e cu t e s.

I f p fi l e i s o m i t t e d f r o m t h e fi r s t f o r m a t , t h e i n s t a l l a t i o n - d e fi n e d d e f a u l t file name is used (PROCFIL is the default).

comment

Specifies an optional parameter that may affect the substitution to be made for a keyword used in the procedure. The value you specify is compared to the appropriate checklist specified for this parameter in the procedure h e a d e r. T h e c h e c k l i s t e n t r i e s a r e c h e c k e d i n a l e f t - t o - r i g h t f a s h i o n a n d

the first match determines the substitution. Refer to the .PROC Directive i n t h i s s e c t i o n f o r m o r e d e t a i l s o n p a r a m e t e r s u b s t i t u t i o n . T h e s p e c i fi c formats for p^ are described later in this subsection.

If you are using the third or fourth format of the BEGIN command as previously shown, there is a 7-character restriction on both the keyword portion and the value portion of the parameter p^.

Specifies the value associated with the comment keyword (ck) on the procedure header. The value consists of any characters you specify following the terminator. If the ck keyword appears on the procedure header, the system substitutes your comment for the comment keyword ck in the procedure body. Otherwise, the system ignores this comment.

r

60459680 G 4-43

For interactive procedures (*I), optional parameters pi can have the following formats:

p . D e s c r i p t i o n

keywrd Specifies a parameter identical to a keyword on the procedure header.

Substitution is controlled by the *K entry in the checklist for the parameter.

k e y wr d ? Spec ifi es inte r a c tiv e B E GIN p roce ssin g ( r e fe r to Re q u e s ti n g H e l p o n o r P r o c e d u r e C a l l s l a t e r i n t h i s s e c t i o n ) .

?

keywrd= Removes keywrd in the procedure body (null substitution) unless overridden b y a c h e c k l i s t s p e c i fi c a t i o n .

keywrd=val Allows order-independent substitution (refer to Parameter Matching Modes in this section), val replaces keywrd in the procedure body unless the

associated checklist specifies otherwise, val can be a 1- to 40-character symbolic name or value. Section 6 describes symbolic names, val can

contain special characters (nonalphanumeric) if they are delimited by dollar signs. Asterisks are the exception; they can appear without dollar sign d e l i m i t e r s .

This parameter format has the following valid variations:

F o r m a t M e a n i n g

k e y w r d = v a l S u b s t i t u t e s t h e s t r i n g v a l f o r k e y w r d .

keywrd=*val+ Substitutes the decimal value of val for keywrd.

keywrd=val+D Same as keywrd=val+.

keywrd=val+B Substitutes the octal value of val for keywrd.

When calling a procedure, a keyword can be named more than once if the keywrd=val parameter format is used each time. The system issues a message informing you that a keyword is named more than once on the command. It uses the value specified with the last occurrence of the keyword.

4 - 4 4 6 0 4 5 9 6 8 0 H

-^Ps

P i D e s c r i p t i o n

Im Dokument C Volume 3 (Seite 125-129)