Updated February 2021
Syntax one:
.ARGTYP(argno)
.ARGSIZ(argno)
These two Dot Functions return the type and size of the specified argument passed to the current SBX, function, or procedure. If argno is invalid, the return value will be -1. The argument types are made up of the bits shown in the following tables.
Syntax two:
.ARGTYP(@arg)
.ARGSIZ(@arg)
The concept here is similar to that used for XPUTARG @arg: @arg is treated essentially as a macro for the argument number corresponding to the argument @arg as defined in the function/procedure definition or as retrieved in an SBX using XGETARG(S).
Symbol |
Value |
Description |
ARGTYP_MASK |
&h000f |
mask for types X,S,F,B,I |
ARGTYP_X |
&h0000 |
X type (mutually exclusive) |
ARGTYP_S |
&h0002 |
S type (" " ") |
ARGTYP_F |
&h0004 |
F type (" " ") |
ARGTYP_B |
&h0006 |
B type (" " ") |
ARGTYP_I |
&h0008 |
I type (" " ") |
Symbol |
Value |
Description |
ARGTYP_ARRAY |
&h0010 |
Array |
ARGTYP_NOSURR |
&h0020 |
No surrogate |
ARGTYP_DYN |
&h0040 |
Dynamic variable |
ARGTYP_LOCAL |
&h0080 |
Local dynamic variable |
ARGTYP_SBR |
&h0100 |
Variable within SBX or XCALL AMOS |
ARGTYP_READONLY |
&h0200 |
See notes below |
Warning: These new functions are not recognized by runtime versions prior to 6.1.1373.0, and will simply return the value of the argno passed. You could use this fact to test if the feature is supported at runtime by passing an illegal argno, such as 999 or -2, to .ARGTYP(argno). If supported, the return value will be -1 (error); else if will match the argno passed. If developing code that might possibly have to run on such an old version, use MX_GETVER or the wrapper function Fn'MinAshVer() in fnminsasver.bsi in SOSLIB:[907,10] to check the version first.
ARGTYP_READONLY
This flag will be set if the passed argument is a literal value, expression, or otherwise incapable of receiving an updated value. This provides a good way for routines to be able to decide whether it is worth generating and returning values for output parameters. For example:
Function Fn'Foo(arg1=0 as b2, arg2="" as s0, arg3=-1 as f6)
...
! calc and return arg3 if not readonly
if not .ARGTYP(@arg3) and ARGTYP_READONLY then
<calculate updated arg3 value>
.xputarg @arg3
endif
...
The new flag is set by the runtime system (beginning in A-Shell 6.4.1553.0) and is independent of the compiler version. Prior versions of the runtime will never set the ARGTYP_READONLY flag and thus logic like that above would would always calculate and output the parameter when running on earlier runtime versions (i.e. dependability over optimization). In the above example, the use of default values will guarantee that the function receives three parameters, but in general, you may want to use the .ARGCNT dot variable, and/or check for special default values, to avoid wasting time, however harmlessly, generating return values for parameters that were not passed.
SBX Example
xgetargs color, rvalue, gvalue, bvalue
xgetarg 5, name
...
if .argtyp(@gvalue) and ARGTYP_B then ... ! if gvalue arg binary
if .argtyp(3) and ARGTYP_B then ... ! if 3rd arg binary (same as above)
if .argtyp(@name) and ARGTYP_S then ... ! if name arg string
The above example illustrates that in the case of an SBX, the @arg reference is based on the order that the referenced variable appears in the xgetargs statement, or the argument number associated with it in a preceding xgetarg statement. Usually the @arg syntax is preferred, since it self-adjusts if you alter the parameter list, but in some cases it might be preferable to stick with the numeric argument numbering.
History
2017 September, A-shell 6.5.1616, compiler edit 834: Add support for .ARGTYP(@arg) and .ARGSIZ(@arg).
2017 July, A-Shell 6.4.1553: ARGTYPE_READONLY added to A-Shell.
2014 September, A-Shell 6.1.1373: Functions added to A-Shell.