Chapter Contents |
Previous |
Next |
METHOD |
Category: | Modular Programming and Object Oriented |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
CALL METHOD(entry,label<,parameters>); |
return-value=METHOD(entry,label<,parameters>); |
Type: Character
Type: Character
Note: These parameters are update parameters. See Input, Output, and Update Parameters for more
information.
Type: Character
Type: Numeric, Character, List, Object, Class, or Interface
Details |
METHOD can pass parameter values to the called method, and it can receive a value when it is used as a function. In order to return a value, the associated METHOD statement must contain the RETURN= option, and the RETURN statement must specify the variable or literal value to return.
Parameters that are passed must agree with the number of arguments, relative positions, and data types in the corresponding method block unless the REST= or ARGLIST= options are used in the method block. The parameter names in METHOD do not have to match the argument names in the method block.
A method block, which contains a sequence of SCL statements, can be defined either in the current SCL entry or in another, external SCL entry. If the method block is defined in the current entry, it is more efficient to use a LINK statement instead of a METHOD routine.
Parameters are passed in the following ways:
An example of a call-by-reference is
call method('b.scl','abc',var1,name,field2);
If you do not want to return the values, use the NOCHANGE() routine in the method block. Or, you can assign the INPUT, OUTPUT, and UPDATE options to the variables listed in the METHOD statement to determine which variables can receive and return values. For example:
abc: method var1 :input :num name :update :char field1 :output :num;
call method('b.scl','abc',100,'hello',x+y);
Example |
Call the method block that is labeled ABC in the SCL entry CODE. The following three parameters are passed: the contents of the variable A, the literal value 3, and the contents of the variable C.
call method('code.scl','abc',a,3,c);
The method block can return modified values to the variables A and C unless the NOCHANGE routine is specified in the method block or unless A and C are not specified in the METHOD statement as input parameters.
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.