Chapter Contents |
Previous |
Next |
SEND |
Category: | Object Oriented |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
CALL SEND(object-id,method-name<,parameters>); |
Type: Numeric or Object
Type: Character
Note: These parameters are update parameters. See Input, Output, and Update Parameters for more
information.
Type: Numeric, Character
Details |
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 8 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.
Example |
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');
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.