Get CGI Variable Count

cgiGetVarCnt

The cgiGetVarCnt procedure retrieves number of occurrences of a variable.

The cgiGetVarCnt procedure is used to retrieve the number of times a field appears in the CGI buffer.

count  cgiGetVarCnt(
  szVarID          256A    Const Varying OPTIONS(*NOPASS)
)

See also: cgiGetVar, cgiInit

Parameters

szVarID [optional] DFT('*KEYWORDS')
[input VChar(256) const]  A string identifying either (A) the type of value whose count is to be returned, or (B) the HTML variable name whose item count is to be returned.
The following table describes each of these options.
Variable ID Description
*KEYWORDS A count of the number of all occurrences of all fields returned to the CGI program. This count is that of all available values.
*FIELDS A count of the number of unique fields in the URL encoded string.
HTML variable A count of the number of occurrences of the specific HTML variable/field.

Return Value

If the function succeeds, the return value is the number of occurrences of the variable or keyword.

If the function fails, zero is returned.

Remarks

First, call cgiInit() once for the invocation of the program, then use this procedure to return the count of the field values or keywords if needed.

Example

.....DName+++++++++++EUDS.......Length+TDc.Functions+++++++++++++++++++++++++
     D i               S             10I 0 
     D nCount          S             10I 0
     D OPTIONS         S             10A   Dim(40)
 
.....C..n01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++++
     C                   callp     cgiInit()
.....C* First get the number of ITEMS selected by the web user
     C                   eval      nCount = cgiGetVarCnt('ITEMS')
.....C* Second, loop through each ITEMS value and store it in an array.
     C                   for       i = 1 to nCount
     C                   eval      Options(i) = cgiGetVar('ITEMS': i )
     C                   endfor