The cgiInit procedure initializes the RPG xTools CGI environment
The cgiInit procedure is used to initialize the CGI environment before calling any of the RPG xTools CGILIB procedures. You should call this procedure before any other CGIxxxxxxxx procedure in your CGI programs.
count cgiInit( nReserved 10I 0 Const OPTIONS(*NOPASS) ) |
|
See also: cgiGetVar, cgiGetVarCnt |
This procedure has no parameters.
If the function succeeds, the return value is the number of bytes of the URL-encoded string that was read by the cgiInit procedure. This is the same value as the CONTENT_LENGTH environment variable but may be slightly different due to the APIs being used to retrieve the URL-encoded string.
If the function fails, the return value is 0.
You must call cgiInit once per CGI application program to initialize the CGI environment before calling cgiGetVarCnt, or cgiGetVar. If the CGI program is receiving a file from the HTML form, the initialization process will read the file into memory before returning. This can increase the time cgiInit takes to process initialize the CGI environment.
In this example the cgiInit routine is called to initialize the CGI environment. This needs to be done once per invocation of the program. Then the cgiGetVar procedure is used to retrieve the data from the HTML Form that evoked the CGI program.
.....DName+++++++++++EUDS.......Length+TDc.Functions+++++++++++++++++++++++++
D CMPNAME S 30A
D CONTACT S 20A
.....C..n01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++++
C If cgiInit() <= 0
C callp wrtjoblog('CGI Init Failed!')
C else
C eval CMPNAME = cgiGetVar('COMPANY')
C eval CONTACT = cgiGetVar('NAME')
C endif