Marked as: Easy
Hello,
OS/2 use message files that contain informative text that can be quite handy to use if you want to add support for various languages. Rexx itself use message files and the commandline and various other apps. use those too. It's possible to access messages in rexx by calling SysGetMessage and therefore also use them in your own scripts.
Each message file can contain several hundred message strings and can therefore take some time to find the right message. I've therefore written this example that both list each message on the screen and at the same time save each message to a file.
Save code to e.g. GetMsg.cmd and run: GetMsg 1000 2000
that will display and save message 1000 to 2000 from the default message file ( OSO001.MSG, see rexx documentation for more info. )
The third parameter can either be a valid message file or the first string to use for messages that use to output text. Remaining parameters should be text and data that the function can use for additional output messages/data/info.
//Jan-Erik
/**** display system messages on the screen and save to file *****/
CALL rxfuncadd 'SysLoadFuncs', 'rexxutil', 'SysGetMessage';
CALL SysLoadFuncs
PARSE ARG num1 num2 str.1 str.2 str.3 str.4 str.5 str.6 str.7 str.8 str.9
IF LENGTH( str.1 ) = 0 THEN str.1 = 'MyText'
DO i = num1 TO num2
IF STREAM( str.1, 'C', 'QUERY EXIST' ) <> '' THEN DO
SAY 'No: 'i SysGetMessage( i, str.1, str.2, str.3, str.4, str.5, str.6, str.7, str.8, str.9 )
CALL LINEOUT 'msg_out.txt', i||' '||SysGetMessage( i, str.1, str.2, str.3, str.4, str.5, str.6, str.7, str.8, str.9 )
END
ELSE DO
SAY 'No: 'i SysGetMessage( i,, str.1, str.2, str.3, str.4, str.5, str.6, str.7, str.8, str.9 )
CALL LINEOUT 'msg_out.txt', i||' '||SysGetMessage( i,, str.1, str.2, str.3, str.4, str.5, str.6, str.7, str.8, str.9 )
END
END
CALL LINEOUT 'msg_out.txt'