Write to Standard Output

cgiStdout

The cgiStdout procedure sends text to the standard-output device.

The cgiStdout procedure is used to send HTML to a web browser, however when called by a non-CGI program the output is routed to the console.

count  cgiStdout(
  szHtmlString             *  Value OPTIONS(*STRING)
  pszSubstitution1         *  Value OPTIONS(*NOPASS:*STRING)
  pszSubstitution2         *  Value OPTIONS(*NOPASS:*STRING)
  pszSubstitutionn...      *  Value OPTIONS(*NOPASS:*STRING)
)

See also: cgiReadData

Parameters

szHtmlString
[input VChar(*) value]  A string of text to be written to the standard output device. Normally HTML is specified to be sent to the client's browser. In addition to text and HTML, the linefeed symbol may be specified. The cgiStdOut procedure supports a linefeed symbol via the standard backslash followed by a lowercase n. (i.e.,  \n) Substitution values are specified by the percent sign followed by a lower case letter 's' (e.g., %s).
 
pszSubstitutionx [OPTIONAL]
[input Char(*) string]  A text value (field, quoted character string, or named constant) that is inserted int othe HTML specified on the szHTMLString parameter before it is sent to the browser. Up to 32 substitution values may be specified. 
 

Return Value

If the function succeeds, the return value is the number of bytes sent to the standard output device.

If the function fails, the return value is zero.

Remarks

You may embed the \n (linefeed) symbol to help with viewing the source from within the web browser. Without linefeeds, the entire HTML source will appear on one line in the VIEW | SOURCE option within the browser. But this existents of linefeeds does not impact the way the HTML is displayed except following a Content-type header or within the <PRE> and </PRE> tags.

Substitution values are optional and may be inserted in the sequence they appear in parameters 2 through 32. To specify a substitution value within the HTML string (szHTMLString parameter) specify the percent sign % followed by the letter "s".  For example:  %s. each occurrence of %s corresponds to the next substitution value.

You may use the values specified for parameters 2 through 32 in any sequence you want. To use them in a sequence other than the default sequence indicated above, specify the substitution value as %n$s where n is the substitution's sequence number on the parameter list. For example, %4$s would use the 4th substitution value.

Example

In the example that follows, two cgiStdOut procedures are called. The first one writes out the so called "content type header" which informs the web browser that it is about to receive HTML. The second call to cgiStdOut writes out the HTML text to the browser, substituting the name 'Bob Cozzi' in the HTML where the "%s" symbols appears.

.....DName+++++++++++EUDS.......Length+TDc.Functions+++++++++++++++++++++++++
     D szHeader        C                   'Content-type: text/html\n\n'
     D szHTML          S           1000A   Varying
     D nCount          S             10I 0
 
.....C..n01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++++
     C                   eval      szHTML = '<HTML>\n<BODY>\n<H1>Hello World +
     C                                       </H1><p>My Name is %s</p>\n +
     C                                       </BODY>\n</HTML>'
     C                   eval      nCount = cgiStdout(szHeader)              
     C                   eval      nCount = cgiStdout(szHTML: 'Bob Cozzi')