![]() Chapter Contents |
![]() Previous |
![]() Next |
| APPLY |
| Category: | Object Oriented |
| Syntax | |
| Details | |
| Example | |
| See Also |
Syntax |
| CALL APPLY(control-id,method-name,arg-list-id); |
|
return-value=APPLY(control-id,method-name,
arg-list-id); |
Type: Numeric
Type: Character
Type: Numeric
Type: Character, List, Numeric, Object, Class, Interface.
| Details |
APPLY provides the functionality of CALL SEND except that you can build a dynamic parameter list at run time instead of coding a fixed parameter list. You can also use APPLY as a function if the called method returns a value with a RETURN statement in the program that defines the method.
| Example |
Instead of using the following statement to invoke a method that you have defined and named METHOD,
control.method(10,'abc','xyz',x);you can use
args = makelist(4); args = setitemn(args,10,1); args = setitemc(args,'abc',2); args = setitemc(args,'xyz',3); args = setitemn(args,x,4); call apply(control,'method',args);
More useful is the ability to combine APPLY with the ARGLIST= and REST= keywords in order to write methods that accept variable argument lists:
length _method_ $40; m: method arglist=args; call apply(otherControl,_method_, args);This calls the method with the same arguments to the otherControl.
For example, a control receiving a method could rebroadcast the method to all controls on its _RECEIVERS_ list:
m: method arglist=args;
_receivers_=getniteml(_self_,'_receivers_',
1, 1, 0);
if _receivers_ then do
r=listlen(_receivers_) to 1 by -1;
call apply(getiteml(_receivers_, r),
_method_, args);
end;
endmethod;
| See Also |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.