home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netdor3.zip / DISK_13 / IMAGE12.ZIP / CATALOG / TIMEXEC.CMD < prev    next >
OS/2 REXX Batch file  |  1993-08-23  |  5KB  |  158 lines

  1. /*****************************************************************************
  2.  *                                TIMEXEC                                    *
  3.  *                     CORE Development (CORE at WATSON)                     *
  4.  *****************************************************************************
  5.  *                    Licensed Materials-Property of IBM                     *
  6.  *               5604-472 (c) Copyright IBM Corporation, 1993                *
  7.  *                           All rights reserved.                            *
  8.  *                  US Government Users Restricted Rights -                  *
  9.  *                 Use, duplication or disclosure restricted                 *
  10.  *                by GSA ADP Schedule Contract with IBM Corp.                *
  11.  ****************************************************************************/
  12.  
  13. /**********************************************************
  14.  * TIMEXEC                                                *
  15.  *                                                        *
  16.  * Purpose: General ADD for TIMEXEC.EXE to userinit.cmd.  *
  17.  *          This can be used by any COREADD that needs    *
  18.  *          TIMEXEC detached from USERINIT.CMD.           *
  19.  **********************************************************/
  20.  
  21. trace '0'
  22. signal on syntax
  23. signal on novalue
  24. call on halt
  25. call rxfuncadd 'CADDINIT', 'RXCADD', 'CADDINIT'
  26. Ver = 'CAddInit'()
  27. if abbrev(Ver, 'ERROR:')
  28.   then exit 200
  29. Title = RxCAdd.STitle 'Installation'
  30. XCode = 0
  31. Env = 'OS2ENVIRONMENT'
  32. call rxfuncadd 'RXCOUINFO', 'COUENV', 'RXCOUINFO'
  33. UserSystemDir = rxcouinfo('GET', 'SYSTEM')
  34. UserSystemDir = strip(UserSystemDir, 'T', '\')||'\'
  35. Dirty = 0
  36.  
  37. select
  38.   when RxCAdd.OpType = 'ADD'
  39.     then do
  40.       Resp = RxRead(UserSystemDir'USERINIT.CMD', 'file')
  41.       if Resp = 0
  42.         then do
  43.           call RxStemGrep 'TIMEXEC', 'file', 'hits', 'N'
  44.           if hits.0 = 0
  45.             then do
  46.               call RxStemGrep 'ECHO OFF', 'file', 'hits', 'N'
  47.               if hits.0 <> 0
  48.                 then parse var hits.1 lnum .
  49.                 else lnum = 0
  50.               call RxStemInsert 'file', lnum+1, '@DETACH TIMEXEC'
  51.               Dirty = 1
  52.             end
  53.         end
  54.         else if Resp = 3
  55.           then do
  56.             file.0 = 3
  57.             file.1 = '@ECHO OFF'
  58.             file.2 = '@DETACH TIMEXEC'
  59.             file.3 = 'EXIT'
  60.             Dirty = 1
  61.           end
  62.           else do
  63.             call 'MessageBox' Title, 'Could not read userinit.cmd file.'
  64.             XCode = 5
  65.           end
  66.       if Dirty
  67.         then do
  68.           if RxWrite(UserSystemDir'USERINIT.CMD', 'file', file.0) <> 0
  69.             then do
  70.               call 'MessageBox' Title, 'Unable to write file USERINIT.CMD.'
  71.               XCode = 6
  72.             end  /* Do */
  73.         end
  74.     end
  75.   when RxCAdd.OpType = 'REMOVE'
  76.     then do
  77.       Resp = RxRead(UserSystemDir'USERINIT.CMD', 'file')
  78.       if Resp = 0
  79.         then do
  80.           call RxStemGrep 'TIMEXEC', 'file', 'hits', 'N'
  81.           do num = 1 to hits.0
  82.             parse var hits.num lnum .
  83.             call RxStemDelete 'file', lnum
  84.             Dirty = 1
  85.           end /* do */
  86.           if Dirty
  87.             then do
  88.               if RxWrite(UserSystemDir'USERINIT.CMD', 'file', file.0) <> 0
  89.                 then do
  90.                   call 'MessageBox' Title, 'Unable to write file USERINIT.CMD.'
  91.                   XCode = 6
  92.                 end  /* Do */
  93.             end
  94.         end
  95.     end
  96.   otherwise do
  97.     call 'MessageBox' Title, 'Unexpected operation type "'RxCAdd.OpType'"'
  98.     XCode = 201
  99.   end
  100. end
  101. call AddExit XCode
  102. exit
  103.  
  104. AddExit:
  105. parse arg XCode, Msg
  106. if XCode = ''
  107.   then XCode = 0
  108. if Msg <> ''
  109.   then call 'MessageBox' Title, Msg
  110. call 'CAddComplete' XCode
  111. call 'CAddExit'
  112. exit XCode
  113.  
  114. /***********************************************************************
  115.  *                             ERROR TRAPS                             *
  116.  ***********************************************************************/
  117. BugInit:
  118. signal off error; signal off failure; signal off halt
  119. signal off novalue; signal off notready; signal off syntax
  120. parse upper source . . Me
  121. if symbol('TITLE') = 'LIT'
  122.   then Title = 'COREADD Failure'
  123. Me = Me':'||'0A'x
  124. if symbol('GLOBALS') = 'LIT'
  125.   then do
  126.     Globals = 'TrVal'
  127.     TrVal = 'O'
  128.   end
  129. return
  130.  
  131. Halt:
  132. Where = SigL
  133. call BugInit
  134. call 'MessageBox' Title, Me||'Execution halted by user in line' Where
  135. XXC = 204
  136. signal DebugExit
  137.  
  138. Syntax:
  139. Where = SigL
  140. call BugInit
  141. call 'MessageBox' Title,,
  142.     Me||'Syntax error' rc '('errortext(rc)') in line' Where'.'
  143. XXC = 203
  144. signal DebugExit
  145.  
  146. Novalue:
  147. Where = SigL
  148. call BugInit
  149. call 'MessageBox' Title, Me||'NOVALUE error ('condition('D')') in line' Where'.'
  150. XXC = 203
  151. signal DebugExit
  152.  
  153. DebugExit:
  154. call 'CAddComplete' XXC
  155. call 'CAddExit'
  156. exit XXC
  157.  
  158.