Receives parameters from the DISPLAY function or routine
| Category: |
Modular Programming
|
|
ENTRY <argument-list>
<RETURN=data-type> <OPTIONAL=argument-list | <ARGLIST=arg-list-id |
REST=rest-list-id>>;
|
-
argument-list
-
lists one or more sets of arguments, with
each set specified as follows:
-
var-list
-
lists one or more variables to which the
parameter in the corresponding position in the DISPLAY routine or function
is passed. For details, see DISPLAY.
-
INPUT |
I
-
specifies that, at run time, the variable
contains the value that is copied from the corresponding parameter of the
calling program. However, when the program finishes, the value is not copied
back to the calling program. This is equivalent to using CALL NOCHANGE() in
the calling program.
-
UPDATE | U
-
specifies that, at run time, the variable
contains the value that is copied from the corresponding parameter of the
calling program. When the program finishes, the value is copied back to that
parameter (unless CALL NOCHANGE is specified).
-
OUTPUT | O
-
specifies that, when the program finishes,
the value is copied back to the corresponding parameter in the calling program.
An error condition results if the corresponding parameter in the calling program
is a constant, because a constant cannot receive a value.
-
data-type
-
specifies the data type of the variable.
Any valid SCL data type may be specifid. A named data type (for example, CHAR
or LIST) must be preceded by the
: delimiter.
The delimiter is optional for unnamed data types (for example, $).
-
arg-list-id
-
contains the identifier for the SCL list
that will contain all the arguments passed to the ENTRY statement. This includes
all optional arguments.
Type: List
-
rest-list-id
-
contains the identifier for the SCL list
that will contain all arguments that are passed to the ENTRY statement but
are not explicitly specified in argument-list
for either ENTRY or OPTIONAL=.
Type: List
The ENTRY statement receives parameters from the DISPLAY
routine or function. It can also return a value if the ENTRY statement contains
both the RETURN= option to declare the data type of the returned value and
a RETURN statement that specifies either the variable containing the value
or the literal value to be returned.
To be compatible with the applications built in earlier
releases of SAS software, the : delimiter
is optional for variables that are assigned unnamed data types (for example,
$), but it is required for variables that are assigned named data types.
The following example shows a variety of data type declarations:
ENTRY: char1 :$20
char2 $20
char3 :input :char(20)
char4 char5:char
num1 :8
num2 8
num3 : num
mylist :list
myobj :object
mybutton :mylib.mycat.button.class return=char;
RETURN=data-type enables
you to return a value to the calling program. An error condition is produced
if data-type is not the same as the type of data
to be returned to the calling program. Use a RETURN statement in the program
to specify the value to return.
When there are no options in the ENTRY statement, there
is a strict correspondence between DISPLAY parameters and ENTRY statement
arguments. The arguments and parameters must agree in number, data type, and
relative position. If you pass an incorrect number of parameters or a parameter
of the incorrect type, SCL stops executing the program. The correspondence
of arguments to parameters is less restrictive when you use the options REST=,
ARGLIST=, and OPTIONAL= in the ENTRY statement.
OPTIONAL= enables you to specify a list of optional
arguments that are used only if the calling program supplies the corresponding
parameters in the DISPLAY parameter list. If the corresponding parameters
in the DISPLAY routine are not supplied, then the optional arguments are initialized
to missing values.
ARGLIST= and REST= enable you to pass a variable number
of parameters to the ENTRY statement. You determine the types and order of
the variable arguments. The lists identified by arg-list-id and rest-list-id are created
automatically when the entry is called, and they are deleted automatically
when the entry ends. When arrays are passed as parameters, the array is expanded
into individual items, and these items are inserted into the arg-list-id and rest-list-id
lists. ARGLIST= and REST= are mutually exclusive, so you can use only one
or the other.
The called program can modify all call-by-reference
arguments that it receives. However, it cannot modify any call-by-value arguments.
For a description of call-by-reference and call-by-value, see DISPLAY
.
By default, values for call-by-reference arguments
are returned to the calling program. If you want a called program to receive
values but not to return values to its calling program, use the NOCHANGE routine.
Or, you can use the INPUT, OUTPUT, or UPDATE option for each variable to specify
how its value is passed and returned.
An SCL program with ENTRY statement arguments cannot
be executed by itself due to the uninitialized arguments. To test a program
that receives parameters via the ENTRY statement, run it with the SCL debugger.
The debugger enables you to initialize all the ENTRY arguments before program
execution starts.
B.SCL contains the following ENTRY statement, which
uses several numeric arguments:
entry x y z u v :i :num return=num;
INIT:
total=x+y+z+u+v;
return(total);
A.SCL contains
total=display('b.scl',1,2,3,4,5);
put total=;The output of A.SCL is
total=15
B.SCL contains the following ENTRY statement, which
defines multiple character variables:
entry x :char(10)
y z :num
optional=u v w :num ;
INIT:
put x= y= z= u= v= w=;
return;Suppose A.SCL contains
call display('b.program','one',2,3,4,5);The output would be
X='one' Y=2 Z=3 U=4 V=5 W=.
B.SCL contains the following ENTRY statement, declaring
both numeric, character, and list variables:
entry x :char(10)
y z :num
optional=u v :num
arglist=mylist;
INIT:
put x= y = z= u= v=;
call putlist(mylist);
return;Suppose A.SCL contains
call display('b.scl','one',2,3,4,5);The output would be
x='one'
y=2
z=3
u=4
v=5('one' 2 3 4 5) [list-id]
Suppose B.SCL contains
entry arglist=mylist;
INIT:
call putlist(mylist);
return; Suppose A.SCL contains
call display('b.scl','one',2,3,4,5);The output would be
('one' 2 3 4 5) [list-id]
B.SCL contains the following ENTRY statement, which
declares numeric variables:
entry x y :num
rest=mylist;
INIT:
put x= y=;
call putlist(mylist);
return;Suppose A.SCL contains
call display('b.scl',1,2,3,4,5);The output would be
x=1
y=2
(3 4 5) [list-id]
B.SCL contains the following ENTRY statement, which
declares both numeric and character variables along with parameter Z, which
is optional:
entry x y :num optional=z :num rest=mylist;
INIT:
put x= y= z=;
call putlist(mylist);
return;Suppose A.SCL contains
call display('b.scl',1,2,3,4,5);The output would be
x=1
y=2
z=3
(4 5) [list-id]
DISPLAY
NOCHANGE
METHOD
RETURN
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.