ARG.PRESENT()

ARG.PRESENT()

Top  Previous  Next

 

The ARG.PRESENT() function tests whether an argument variable was passed by the caller of a subroutine or function declared with the VAR.ARGS option.

 

 

Format

 

ARG.PRESENT(var)

 

where

 

varis the name of an argument variable.

 

 

When a program calls a subroutine or function that has been declared with the VAR.ARGS option, the actual number of arguments passed may be fewer than the number of argument variables in the subroutine definition. The unused argument variables will be left unassigned. The ARG.PRESENT() function allows the subroutine or function to test whether the argument was passed by the caller. Use of default values for missing arguments does not affect the value returned by this function.

 

Note that the ARG.PRESENTT() function relates to the arguments passed into a SUBROUTINE, FUNCTION or CLASS module and does not reflect the number of arguments passed into a local subroutine or function.

 

 

Example

 

SUBROUTINE INCREMENT.COUNTER(CT) VAR.ARGS

  READU REC FROM @VOC, 'COUNTER' ELSE STOP 'COUNTER missing'

  IF ARG.PRESENT(CT) THEN CT = REC<2>

  REC<2> += 1

  WRITE REC TO @VOC, 'COUNTER'

  RETURN

END

 

The above subroutine increments a counter stored in field 2 of a VOC X-type record. If the CT argument is present in the call to this subroutine, the previous value of the counter is returned via this argument.

 

 

See also:

ARG(), ARG.COUNT(), SET.ARG