System Functions
MSG( ) Return Message Text
   
     
Formats
1. By Message Number: MSG(err_msg,[,ERR=stmtref])
2. By Message Key: MSG( [ = ] msg_key$,[param1, param2, ...][,ERR=stmtref])
3. Message Library Setting: MSG(*)
4. Get OS error message: MSG( + [ : oserrcode ] )

Where:

* 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$).
err_msg Number of the error message to return. Numeric expression. If err_msg is a positive integer, it returns the associated message, as described under Error Codes and Messages,. If err_msg is -1, it returns extended or external error information.
msg_key$ Message key to the Message Library file. String expression. If an EQUAL sign preceeds 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.
oserrcode The optional operating system error code (from GetLastError Windows API call or errno under Unix/Linux).
param1, Optional parameters. You can use a list of values to replace the
param2, ... parameters stored in the message.
stmtref Program line number or statement label to which to transfer control.
   
Returns Text associated with given message number or key.
   
Description 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 in ProvideX by a program and to return information from your own message libraries.

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

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

Format 4 of the MSG function is a +PxPlus Exclusive feature.

   
See Also DEF MSG Directive
MESSAGE_LIB Directive
   
Examples 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:

0010 ! Returns the current message library name, if any is in effect
0020 PRINT MSG(*)

Example 4:

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

-:?msg(14)
Error #14: Invalid I/O request for file state