SD - The Open Source, Multivalue, String, Database

OpenQM 2.6.6 documentation for this command is available here.  The OpenQM documentation may provide additional context for this command.  However, some features in SD have been modified so the OpenQM information may not be 100% applicable to SD.

SD Basic Functions - ARG.COUNT()

Format:  ARG.COUNT()

The ARG.COUNT() function returns the number of arguments passed into the current subroutine. It is intended for use with subroutines declared with the VAR.ARGS option.

Format:  ARG.COUNT()

When a program calls a subroutine 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.COUNT() function allows a subroutine to determine the number of arguments that have been passed. See the ARG() function for a way to access arguments by their position in the argument list.

When used in a function, the value returned by ARG.COUNT() excludes the hidden return argument.

Example

FUNCTION AVG(A,B,C,D,E) VAR.ARGS
  TOTAL = 0
  FOR I = TO ARG.COUNT()
     TOTAL += ARG(I)
NEXT I

  RETURN TOTAL / ARG.COUNT()

END

The above function returns the average of the supplied arguments. Because this function is declared with the VAR.ARGS option, the ARG.COUNT() function is used to determine the actual number of arguments and the ARG() function is used to access each argument by its position.