Chapter Contents |
Previous |
Next |
SUPAPPLY |
Category: | Object Oriented |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
CALL SUPAPPLY(object-id,method-name,arg-list-id); |
return-value=SUPAPPLY(object-id,method-name,arg-list-id); |
Type: Numeric or Object
Type: Character
Type: Numeric
Type: Numeric, Character, List, Object-name, Class, or Interface
Details |
SUPAPPLY provides the same functionality as SUPER except that you can pass arguments to inherited methods in an SCL list. You use SUPAPPLY to execute an inherited method when you define another method that performs additional actions. A method that calls an inherited method and includes additional actions is called an overloaded method. See Overloading Methods for more information.
In Version 8, you must use dot notation to call overloaded methods. Dot notation provides compiler time checking and better performance at run time. With overloaded methods, the compiler must be able to check method signatures in order to call the correct method. For details about dot notation, see Accessing Object Attributes and Methods With Dot Notation.
You can use SUPAPPLY as a function if the called method returns a value with a RETURN statement in the program that defines the method.
Although the method name is typically the name of the currently executing method, which is stored in the system variable _METHOD_, any other method name can be used.
The object identified by object-id
must be the same object whose method is currently executing. The identifier
for this object is stored in the system variable _SELF_. In methods defined
in a CLASS or USECLASS statement block, all references to the class methods
and attributes can bypass references to _SELF_.attribute
and _SELF_.method(...). For example, to call
a super method with dot notation in a method definition, you can use
supapply();
, which is equivalent
to
call supapply(_self_,'m1');
.
Example |
Consider an Object class in which a Transaction method
receives a variable-length parameter list of transactions to record in a table.
A subclass of this class records the transactions in an audit trail table
that contains two numeric variables, DATETIME and TCOUNT. These variables
record the date/time and the number of transactions processed. This example
shows the Transaction method, which invokes the inherited Transaction method
and then records the size of the transaction (the number of items in the argument
list) for a table. The object has the attributes audit
, tc_vmum
, and dt_vnum
.
Audit
is a table ID for an audit table. Tc_vnum
is the variable number for the TCOUNT variable. Dt_vnum
is the variable number for the DATETIME variable.
useclass lib.cat.myclass.class; /* TRANSACT.SCL: TRANSACTION method */ Transaction: method arglist= transactions; call supapply(_self_,'Transaction',transactions); if audit then do; nTransactions=listlen(transactions); call putvarn(audit,tc_vnum,nTransactions); call putvarn(audit,dt_vnum,datetime()); rc=update(audit); end; endmethod; enduseclass;
This method can be invoked with an arbitrary number
of transactions using dot notation, where the SCL variable listOftransactions
is an SCL list that contains one or more
transaction objects.
dcl lib.cat.myclass.class obj=_NEW_lib.cat.myclass(); obj.Transaction(t1,t2,t3,t4,t5); obj.Transaction(t1,t2); obj.Transaction(listOftransactions);
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.