That could be an order of three items, each with a
different quantity.
In other words, the CGI receives multiple occurrences
of input variables
imtemno and
qty.
CGIDEV2 service program provides the following procedures:
- ZhbGetVarCnt returns the number of multiple occurrences
of a given input field
- ZhbGetVar returns the value of one of
the multiple occurrences of a given input field
- ZhbGetVarUpper returns the value of one of
the multiple occurrences of a given input field
in uppercase characters
Example:
* Prototype definitions and standard system API error structure
/copy CGIDEV2/qrpglesrc,prototypeb
/copy CGIDEV2/qrpglesrc,usec
* Number of variables
DnbrVars s 10i 0
* Saved query string
Dsavedquerystring...
D s 32767 varying
* Return code
D rc s 10i 0 inz(0)
* Variables for retrieving multiple occurrencies of "itemno" and "qty"
D itemcount s 10i 0
D varocc s 10i 0
*
D itemno s 5a
D qty s 3a
* ... etc. ...
* Get input
C eval nbrVars =
C zhbgetinput(savedquerystring:qusec)
* Example of multiple occurences
C eval itemcount = ZhbGetVarCnt('itemno')
C IF itemcount > 0
C 1 do itemcount varocc
C eval itemno = ZhbGetVar('itemno':varocc)
C eval qty = ZhbGetVar('qty':varocc)
C exsr ProcessItem
C enddo
C ENDIF |
These procedures are able to process
an unlimited number of
occurrences of the same
input variable.
For an example of retrieving multiple occurrences
of an input variable, please check out program
boatsch2
in the YachtWorld demo.
|