System Functions

MSG( )

Return Message Text


1. By Message Number:


2. By Message Key:

MSG( [ = ] msg_key$,[param1, param2, ...][,ERR=stmtref])

3. Message Library Setting:


4. Get OS Error Message:

MSG( + [ :oserrcode ] )   (added in PxPlus v8.0)



MSG(*) returns the current MESSAGE_LIB settings. If more than one MESSAGE_LIB is open, the function returns all the open filenames in search order, each separated by the default field separator, SEP (e.g. $8A$).


Number of the error message to return. Numeric expression. If err_msg is a positive integer, it returns the associated message (see Error Codes and Messages). If err_msg is -1, it returns extended or external error information.


Message key to the Message Library file. String expression. If an = (equals sign) precedes the msg_key$ in the function call, the msg_key$ value is assumed to be the contents of the entry in the message. This allows for direct substitution within data strings.


Optional operating system error code (from GetLastError Windows API call or errno under UNIX/Linux).

param2, ...

Optional parameters. You can use a list of values to replace the parameters stored in the message.


Program line number or statement label to which to transfer control.


Text associated with given message number or key.


The MSG( ) function returns the text of the message whose number or key is specified. Use this function to obtain more information about errors generated by a program and to return information from your own message libraries.

Use the DEF MSG directive to temporarily override the MSG( ) function.

To permanently define different system messages for a different language, create a *mlfile.xx for a different language and use the *msgupd program to define all the messages. See Customizing System Messages for Different Languages.

Format 4 returns the operating system error message either for the current error condition (if no oserrcode given) or for the error code specified.

See Also

DEF MSG Define Temporary Message
MESSAGE_LIB Establish Message Library


The following examples illustrate the different uses for the MSG( ) function:

Example 1:

0010 open (1,err=1000)"PRINTR"
0020 open (2,err=1000)"CUSTOM"
0030 read (2,key="",err=1000)R$
0040 ...
1000 print "Could not open PRINTR",'LF',msg(ret)
1010 stop

Example 2:

keyed "MESSAGE.LIB",20,0,-256
open (1)"MESSAGE.LIB"
write record (1,key="NOCUST")"Sorry but Customer %1 is not valid"
close (1)
message_lib "MESSAGE.LIB"
print msg("NOCUST","0001")

Sorry but Customer 0001 is not valid

Example 3:

! Returns the current message library name, if any is in effect
     print msg(*)

Example 4:

Use this function to obtain the PxPlus error message associated with an error number:


Error #14: Invalid I/O request for file state