Arguments of Type ANY
- Last UpdatedOct 21, 2022
- 1 minute read
You may specify ANY as the type of an argument (and even as the type of the function return value).
Note:
The use of ANY should be the exception rather than the rule as it switches off argument
type checking - an important feature of PML functions to help make sure correct functioning
of your PML.
In the case an argument of type ANY, a value of any type may be passed as the argument to the function:
define function !!Print(!Argument is ANY)
$P $!Argument
endfunction
Where an argument of type ANY is used, you need to find out its actual type before you can do anything with it. The ObjectType() method can be used for this purpose:
define function !!AnyType(!Argument is ANY)
Type = !Argument.objectType()
if ( !Type EQ 'STRING' ) then
-- assign to STRING type of variable and work with it
!stringArg = !Argument
elseif ( !Type EQ 'REAL' ) then
-- assign to REAL type of variable and work with it
!realArg = !Argument
elseif ( !Type EQ 'DBREF' ) then
-- assign to DBREF type of variable and work with it
!dbrefArg = !Argument
else
-- do something with all other types or give an error
$P "Unsupported type of argument!"
endif
endfunction