home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxxpl201.zip / REXXPL.CMD next >
OS/2 REXX Batch file  |  1998-01-15  |  5KB  |  138 lines

  1. /*
  2.      REXXPL.CMD v2.0 [REXXPL20.ZIP]  C.L.Distefano rev. 1/15/98
  3.        Embed Rexx code in XyWrite (XPL) programs ("RexXPL!")
  4.        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5.  
  6. Developers:  
  7. **********/
  8. DEBUG=0 /* <== Set DEBUG=1 to suppress deletion of temp files
  9.                R2XTMP.CMD & R2XTMP.TMP, located in BootDrive:\OS2\MDOS
  10.                Rexx output file is copied to OUTPUT.DBG for inspection
  11. *********************************************************************/
  12.  
  13. if RxFuncQuery('SysLoadFuncs') then do
  14. call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  15. call SysLoadFuncs
  16. end
  17.  
  18. call SysIni 'BOTH','FolderWorkareaRunningObjects','ALL:','Objects'
  19. BtDrv=translate(left(Objects.1,1)) /* BootDrive letter */
  20.  
  21. RxPath=BtDrv':\OS2\MDOS\'
  22.  
  23. exec=RxPath'R2XTMP.CMD'
  24. flag=RxPath'OUTPUT.OK'
  25. infile=RxPath'R2XTMP.TMP'
  26.  
  27. linein(infile,1,0)
  28. if lines(infile)=0 & debug\=1 then do
  29.   say
  30.   say 'REXXPL.CMD v2.0 [REXXPL20.ZIP]  C.L.Distefano  rev. 1/15/98'
  31.   say 'Include Rexx procedures in XyWrite programs (Rexx+XPL)'
  32.   say
  33.   say 'REXXPL.CMD is called by XyWrite (U2) routine "R2X"'
  34.   say 'It is not issued directly from the OS/2 command line'
  35.   say
  36.   exit 99
  37.   end
  38.  
  39. if stream(exec,'C','query exists')\='' then call SysFileDelete exec
  40. if stream(flag,'C','query exists')\='' then call SysFileDelete flag
  41.  
  42. rc=lineout(exec,,1)
  43.  
  44. call lineout exec, '/* R2XTMP.CMD */'
  45. call lineout exec, 'signal on Failure; signal on Syntax; signal on Error'
  46. call lineout exec, 'Lg=x2c("AE"); Rg=x2c("AF")'
  47. call lineout exec, 'EOF=x2c("1A"); CrLf=x2c("0D0A")'
  48. call lineout exec, 'BtDrv="'||BtDrv||'"'
  49. call lineout exec, 'OUTPUT.R2X=""; Protect=""; xy.=""'
  50. call lineout exec, 'flag="'||flag||'"'
  51.  
  52. do while lines(infile)>0
  53.   call lineout exec, linein(infile)
  54.   end
  55. call stream infile, 'C', 'close'
  56.  
  57. call lineout exec, 'Exit:'
  58. call lineout exec, 'if Protect=1 then signal Coda'
  59. call lineout exec, 'if length(SGs)>25 then say "Working ..."'
  60. call lineout exec, 'do while pos(",",SGs)>1'
  61. call lineout exec, ' parse var SGs IDz "," SGs'
  62. call lineout exec, 'OUTPUT.R2X=OUTPUT.R2X||Lg"SV"IDz","xy.IDz||Rg'
  63. call lineout exec, 'end'
  64. call lineout exec, 'do while pos(EOF,output.r2x)>0'
  65. call lineout exec, 'posEOF=pos(EOF,output.r2x)'
  66. call lineout exec, 'output.r2x=insert(x2c('5BF262E92ACD1ED458C05D'),,'
  67. call lineout exec, ' delstr(output.r2x,posEOF,1),posEOF-1)'
  68. call lineout exec, 'end'
  69. call lineout exec, 'output.r2x=translate(output.r2x," ",x2c("00"))'
  70.  
  71. call lineout exec, 'Coda:'
  72. call lineout exec, 'if Protect\=1 then do'
  73. call lineout exec, 'call directory "'RxPath'"'
  74. call lineout exec, 'tempfile=SysTempFilename("OUTPUT??.???")'
  75. call lineout exec, 'call stream tempfile,"C","open write"'
  76. call lineout exec, 'call charout tempfile,output.r2x,1'
  77. call lineout exec, 'call stream tempfile,"C","close"'
  78. if debug=1 then call lineout exec,,
  79.  '"@copy "tempfile" 'RxPath'OUTPUT.DBG>nul"'
  80. call lineout exec, '"@ren "tempfile" output.ok"'
  81. call lineout exec, 'end'
  82.  
  83. call lineout exec, 'EXIT 0'
  84.  
  85. call lineout exec, 'Read:'
  86. call lineout exec, 'tmpSG=""'
  87. call lineout exec, 'call stream SGfile,"C","open read"'
  88. call lineout exec, 'do while chars(SGfile)>1'
  89. call lineout exec, 'tmpSG=tmpSG||charin(SGfile)'
  90. call lineout exec, 'end'
  91. call lineout exec, 'call stream SGfile,"C","close"'
  92. call lineout exec, 'call SysFileDelete SGfile'
  93. call lineout exec, 'drop SGfile'
  94. call lineout exec, 'return'
  95.  
  96. call lineout exec, 'Syntax:'
  97. call lineout exec, 'if Protect\=1 then do'
  98. call lineout exec, '  output.r2x=Lg"SV711,Error (syntax): "sourceline(sigl)||Rg||,'
  99. call lineout exec,    'Lg"SV712,Explanation: "Errortext(rc)||Rg'
  100. call lineout exec, '  signal Coda'
  101. call lineout exec, '  end'
  102. call lineout exec, 'else call beep 750,500'
  103. call lineout exec, 'say "Error (syntax): "sourceline(sigl)'
  104. call lineout exec, 'say "Explanation:    "Errortext(rc)'
  105. call lineout exec, 'exit rc'
  106.  
  107. call lineout exec, 'Failure:'
  108. call lineout exec, 'if Protect\=1 then do'
  109. call lineout exec, '  output.r2x=Lg"SV711,Error (failure): "sourceline(sigl)||Rg||,'
  110. call lineout exec,    'Lg"SV712,"SysGetMessage(rc)||Rg'
  111. call lineout exec, '  signal Coda'
  112. call lineout exec, '  end'
  113. call lineout exec, 'else call beep 750,500'
  114. call lineout exec, 'say "Error (failure): "sourceline(sigl)'
  115. call lineout exec, 'say SysGetMessage(rc)'
  116. call lineout exec, 'exit rc'
  117.  
  118. call lineout exec, 'Error:'
  119. call lineout exec, 'if Protect\=1 then do'
  120. call lineout exec, '  output.r2x=Lg"SV711,Error (rc="||rc||"): "sourceline(sigl)||Rg||Lg"SV712,"||SysGetMessage(rc)||Rg'
  121. call lineout exec, '  signal Coda'
  122. call lineout exec, '  end'
  123. call lineout exec, 'else call beep 750,500'
  124. call lineout exec, 'say "Error (rc="||rc||"): "sourceline(sigl)'
  125. call lineout exec, 'say SysGetMessage(rc)'
  126. call lineout exec, 'exit rc'
  127.  
  128. call stream exec, 'C', 'close'
  129.  
  130. '@call 'exec
  131.  
  132. if debug\=1 then do
  133.   call SysFileDelete infile
  134.   call SysFileDelete exec
  135.   end
  136.  
  137. EXIT 0 /* REXXPL.CMD */
  138.