home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxlbox13.zip / getMsg1.cmd < prev    next >
OS/2 REXX Batch file  |  1998-03-01  |  2KB  |  53 lines

  1. /* ------------------------------------------------------------------ */
  2. /*                                                                    */
  3. /* simple routine to read messages from a message file for the        */
  4. /* RXLBOX sample no. 3                                                */
  5. /*                                                                    */
  6. /* Usage: GETMSG1 msgNo {,msgParameter1 {,...} {,msgParameter9}}      */
  7. /*                                                                    */
  8. /* ------------------------------------------------------------------ */
  9.  
  10.   parse arg msgNo
  11.  
  12.   curDir = directory()
  13.   if right( curDir, 1 ) = '\' then
  14.     curDir = dbrright( curDir, 1 )
  15.  
  16.   msgFile = curDir || '\SAMPLE3.MSG'
  17.  
  18.   curMsgNo=0
  19.   do while curMsgNo <> msgNo & lines( msgFile ) <> 0
  20.     parse value lineIN( msgFile ) with curMsgNo '=' curMsgText
  21.   end /* do */
  22.  
  23.   call stream msgFile, 'c', 'CLOSE'
  24.  
  25.   if curMsgNo = MsgNo then
  26.   do
  27.                     /* replace the placeholder with the values        */
  28.     if pos( '%', curMsgText ) <> 0 then
  29.     do
  30.                     /* this loop processes the parameter 3 to n       */
  31.       do j = 1 to 9
  32.         pString = '%' || j
  33.  
  34.         do forever
  35.           if pos( pString, curMsgText ) = 0 then
  36.             leave
  37.           parse var curMsgText part1 ( pString ) part2
  38.           curMsgText = part1 || arg( j+1 ) || part2
  39.         end /* do forever */
  40.  
  41.       end /* do j= 1 to 9 */
  42.  
  43.     end /* if pos( '%', curMsgText ) <> 0 then */
  44.  
  45.     return CurMsgText
  46.   end /* if curMsgNo = MsgNo then */
  47.   else
  48.     return '???'
  49.  
  50. /* ------------------------------------------------------------------ */
  51. /*                                                                    */
  52. /* ------------------------------------------------------------------ */
  53.