cgi Send Message ID as HTML

cgiSndMsgID

The cgiSndMsgID procedure retrieves a message from the specified message file and formats the message with HTML, it then sends that HTML to the standard-output (stdout) device for display in a web browser.

The cgiSndMsgID procedure prepares a traditional CPF or user-specified message ID for output to a web browser as HTML and then sends that HTML to the stdout device.

nBytesWritten  cgiSndMsgID(
 szMsgID         7A    Const 
 szMsgFile      21A    Const OPTIONS(*NOPASS : *OMIT)
 szMsgData     512A    Const OPTIONS(*NOPASS : *OMIT : *VARSIZE)
 nMsgDataLen    10I 0  Const OPTIONS(*NOPASS : *OMIT)
 nOptions       10I 0  Const OPTIONS(*NOPASS : *OMIT)
 nMsgOptions    10I 0  Const OPTIONS(*NOPASS : *OMIT)
)

See also: cgiFmtMsgID, GetMsgText, SetMsgPrefix

Parameters

szMsgID
[input Char(7) const]  This parameter specifies the message ID to be retrieved. A full or partial message ID may be specified. That is a full message ID including the 3-character message prefix, or just the 4-position message ID "number" may be passed. If the message ID is less than 4 position in length, it is padded on the left with zeros.
 

Valid formats for message identifiers are as follows:

 *...v....1
'CFP1006'
'1006'
'CFP0106'
'106'
 
szMsgFile [optional]
[input Char(21) const]  Message file name. This parameter consists of two parts (1) in the first 10 positions, the name of the message file, and (2) in the second 10 positions, the name of the library containing the message file For example:
 
 *...v....1....v....2
'QCPFMSG   QSYS      '
 

An alternative syntax is also supported for the message file name parameter. The alternate syntax allows you to specify the message file name similar to that of an OS/400 CL command, that is it may be qualified using qualified name syntax, as follows:

 *...v....1....v....2
'QSYS/QCPFMSG        '
 

 

szMsgData [optional]
[input Char(512) const]  Specify the message data that will be substituted within the returned message text. If a regular character field (non-data structure) is passes for this parameter, then the 3rd parameter, nMsgDataLength, is not necessary. If a data structure is passes for this parameter, then specify the length of the value passed on the nMsgDataLength parameter.
 
nMsgDataLen  [optional]
[input Int4 (10i0) const]  Specify the length of the message data specified on the 2nd parameter, szMsgData. If the szMsgData parameter is unspecified, or if a regular field or named constant is specified, this parameter may be specified, but is unnecessary as the procedure can determine the length. If a data structure is passed on the szMsgData parameter, then you must pass the length of that data structure (or some other value) on this parameter.  If a data structure is specified, you can use the %SIZE(ds) built-in function to specify the data structure length for this parameter; where "ds" is the name of the data structure being passed. 
nMsgOptions  [optional]  DFT(3)
[input Int4 (10i0) const]  If specified, this parameter may be one of the following values.
 
Options Description
1 Send only the 1st level message text
2 Send only the 2nd level message text
3 Send the entire message (1st and 2nd level message text)
 
nOptions  [optional]  DFT(1)
[input Int4 (10i0) const]  If specified, this parameter may be one of the following values. 
Options Description
1 Send the standard CGI Header Content-type text/html  before sending the formatted HTML to stdout.
0 Do not send the Content-type header before writing to stdout.

Overriding the Message Settings

To override the default message file name being used to extract the messages, use the SetMsgProp (Set message properties) procedure. The default message file name is QCPFMSG on the library list.

Return Value

The return value is the number of bytes written to stdout.

Example

To send message ID USR1234 in QUSRMSG as HTML to standard output (stdout), the following may be used:

     /INCLUDE XTOOLS/QCPYSRC,cgi
.....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++++++++

     C                   Eval      cgiSndMsgID('USR1234':'QUSRMSG')

In this example, the formatted HTML message is written to stdout.