Sends a method to an object using its identifier and can return
a value from a called method
| Category: |
Object Oriented
|
|
CALL
SEND(object-id,method-name<,parameters>);
|
|
return-value=SEND(object-id,method-name<,parameters>);
|
-
object-id
-
contains the identifier that is associated
with the object for which the method is invoked.
Type: Numeric or Object
-
method-name
-
is the name of the method to send. The
method must be defined for the object's class or for one of the classes from
which the object inherits methods. Case and trailing blanks are ignored in
method names.
Type: Character
-
parameters
-
specifies one or more numeric or character
parameters that are required by the method. Use commas to separate multiple
parameters.
Type: Numeric, Character
-
return-value
-
contains the value returned by method-name. The data type for return-value should match the data type for
the called method.
Type: Numeric, Character, List, Object, Class, or Interface
SEND passes one or more arguments to a method in the
form of parameters to the routine. The method may modify any of these parameters
and pass values back to the calling program via the parameters, or the method
may modify the object's automatic system variables. You can use the _getWidget
method to return the object-id for a control.
You can also use SEND as a function if the called method
returns a value with a RETURN statement.
The classes provided with SAS/AF software include a
set of predefined methods. Subclasses that you define from these classes inherit
those methods. You can also define your own methods. Methods are defined with
the METHOD statement in an SCL entry, or they may be entire SAS/AF entries.
(SCL, PROGRAM, FRAME, HELP, and MENU entries are allowed.) A METHOD statement
uses the syntax of an ENTRY statement to declare the types and names of the
parameters that the method expects.
The parameters that are passed to SEND must match the
parameter definitions of the METHOD or ENTRY statement of the method. You
can specify optional parameters, using the OPTIONAL= option for the METHOD
or ENTRY statement of the method. You can specify variable lengths and types
for parameters, using the ARGLIST= and REST= options in the METHOD or ENTRY
statement of the called method.
The same method may be defined for one or more classes;
each class has its own definition of the method. Therefore, when a method
is invoked, the appropriate method definition is determined based on the object's
class. If the specified method is not defined for the object's class, SAS/AF
searches the hierarchy of parent classes for the method definition.
When a method executes, the SCL variable _SELF_ is automatically
initialized to the object identifier object-id,
enabling the method to invoke other methods for the same object. Also, any
of the object's automatic system variables are initialized if the SCL program
uses a variable of the same name and type as the automatic system variable.
If a character variable named _METHOD_ is declared, it will be initialized
with the method name.
If an SCL method executes a SEND or otherwise invokes
a method, the values of all automatic SCL variables in the calling method
are copied into the object. After the called method executes, the automatic
SCL variables are re-initialized with the values of the caller's system variables.
Other routines that execute methods are APPLY, NOTIFY, SUPAPPLY, and SUPER.
To send methods to Version 7 objects, you should use
dot notation instead of CALL SEND. Dot notation provides compiler time checking
and better performance at run time. For more information about dot notation,
see Accessing Object Attributes and Methods With Dot Notation.
Using dot notation is the only way to call overloaded
methods, because the compiler must be able to check method signatures in order
to call the correct method.
For example, to send a message to an object using dot
notation, you could use
_frame_._setMsg('Table '||tablename||
' does not exist');
(The system variable _FRAME_ contains the identifier
for the frame.)
Note:
If a component is a control in
an extended table, then you can invoke methods only during the getrow and
putrow sequences or for _init and _term methods. Also, in a FRAME SCL entry,
to send methods to controls in an extended table, you can use NOTIFY rather
than SEND. ![[cautend]](../common/images/cautend.gif)
Send a _term method to an icon whose name is ICON1 and
whose identifier is stored in the variable ICON1ID:
call send(_frame_,'_getWidget','icon1',icon1id);
call send(icon1id,'_term');
APPLY
ENTRY
INSTANCE
LOADCLASS
LOADRES
METHOD
NOTIFY
SUPAPPLY
SUPER
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.