Please enable JavaScript to view this site.

A-Shell Reference

Parameters can be passed to and from SBX routines. In most cases the mechanism, techniques and capabilities are essentially the same, whether we are talking about SBX routines or functions/procedures, although there are some syntax differences and limitations that apply to SBXs.

In all cases the caller passes the parameters in a comma-delimited list as part of the call, with the compiler identifying the parameter types automatically.  On the receiving end, the SBX must use XARG Statements to retrieve them. Functions can do the same, but normally receive the parameters automatically based on the function declaration. To send parameters back to the caller, both SBXs and functions use XPUTARG. For example:

! (In caller)

xcall MYSBX, arg1, arg2, ... argN   ! arguments passed to SBX

! (in MYSBX.SBX)

xgetargs var1, var2, ... varN       ! receiving the passed arguments within SBX

...

xputarg @var1                       ! sending var1 back to arg1

xputarg @var2=xyz                   ! sending xyx back to arg2

 

The above example illustrates the most typical situation, which involves passing of ordinary scalar parameters by value. The following subtopics provide additional details about more advanced aspects of parameter passing such as passing arrays, using named parameters, etc.  Note that the topics may apply to both SBXs and functions, with differences between them noted accordingly.

Parameter Passing (Collections): Passing Collection Elements, Passing Collections