home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / TOOLKIT / CREXX / REXXUTIL / REXXUDEM.CMD < prev    next >
OS/2 REXX Batch file  |  1994-11-17  |  9KB  |  288 lines

  1. /*******************************************************************/
  2. /*                                                                 */
  3. /* REXXUDEM.CMD                                                    */
  4. /*                                                                 */
  5. /* This program calls the various REXX external functions          */
  6. /* provided in the REXXUTIL.C sample function package.             */
  7. /*                                                                 */
  8. /* Each function is called once to illustrate how it is used.      */
  9. /* Some of the functions have multiple options and multiple        */
  10. /* types of output, but not all options are used here.             */
  11. /*                                                                 */
  12. /* Some of the functions in REXXUTIL only work in windowed         */
  13. /* or fullscreen command prompt sessions, not in PMREXX.           */
  14. /* This is because they are doing vio-type operations such as      */
  15. /* placing the cursor at a particular place on the screen.         */
  16. /* So if this program is run in PMREXX, it will start a new        */
  17. /* windowed session and run itself there.                          */
  18. /*                                                                 */
  19. /*******************************************************************/
  20. '@echo off'
  21.  
  22. /* Detect if we are running under PMREXX.                          */
  23. /* Some of the REXXUTIL functions (such as SysCurPos) only work    */
  24. /* in OS/2 command prompt sessions, not in PMREXX.                 */
  25. If Address() = 'PMREXX' Then  Do
  26.   Say 'This program will now run itself in a windowed '
  27.   Say '  command prompt session'
  28.   'START REXXUDEM.CMD /C /WIN'
  29.   Exit
  30.   End
  31.   /* We now know we are running in a line-mode session.            */
  32.  
  33. /* For several of the functions, we will need to write to some     */
  34. /* drive on the system.  We decide in advance what drive that      */
  35. /* will be.  Our method is:  Look for :\OS2\SYSTEM in the PATH.    */
  36. /* If found, use the preceding character.  Otherwise, default to C.*/
  37. path = value('PATH',,'OS2ENVIRONMENT')
  38. if pos(':\OS2\SYSTEM', path) > 1 then
  39.    Parse Upper var path . ":\OS2\SYSTEM" -1 bootdrive +1 .
  40.    else bootdrive = 'C'
  41.  
  42.  
  43. /* SysLoadFuncs:  This function will load all the rest,            */
  44. /* so we do not have to make many calls to RxFuncAdd.              */
  45.  
  46. Say 'This program will call many of the REXX functions provided'
  47. Say '  in REXXUTIL.DLL.  The first one is SysLoadFuncs, which makes'
  48. Say '  all the others available.'
  49. call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  50. call SysLoadFuncs
  51. Say 'SysLoadFuncs is complete.'
  52. call SysPause                     /* This is an internal function. */
  53.                                   /* See below.                    */
  54.  
  55.  
  56. /*** Demonstrate SysCls ***/
  57. call SysCls; say
  58. call SysPause 'Demonstrating SysCls, press Enter key...'
  59. call SysCls
  60. say; say 'Did you see that quick screen-clear via SysCls?'
  61. call SysPause
  62.  
  63.  
  64. /*** Demonstrate SysCurPos ***/
  65. call SysCls
  66. say; say 'Demonstrating SysCurPos...'
  67. call SysCurPos '3', '0'
  68. call SysPause 'Press a key'
  69. call SysCurPos '10', '50'
  70. call SysPause 'Press a key'
  71. call SysCurPos '20', '20'
  72. call SysPause 'Press a key'
  73. call SysCurPos '5', '65'
  74. call SysPause 'Press a key'
  75. call SysCurPos '23', '0'
  76. call SysPause
  77.  
  78.  
  79. /*** Demonstrate SysCurState ***/
  80. call SysCls
  81. call SysCurState 'OFF'
  82. say; say 'Demonstrating SysCurState..'; say
  83. call SysPause 'Note that the cursor is hidden.  Press Enter key...'
  84. call SysCurState 'ON'
  85.  
  86.  
  87. /*** Demonstrate SysDriveInfo ***/
  88. call SysCls
  89. say; say 'Demonstrating SysDriveInfo by displaying',
  90.           bootdrive': drive info:'
  91. say SysDriveInfo(bootdrive':')
  92. call SysPause
  93.  
  94.  
  95. /*** Demonstrate SysDriveMap ***/
  96. call SysCls
  97. say; say 'Demonstrating SysDriveMap by displaying all available drives:'
  98. say SysDriveMap()
  99. call SysPause
  100.  
  101.  
  102. /*** Demonstrate SysGetMessage ***/
  103. call SysCls
  104. say; say 'Demonstrating SysGetMessage by reading message #34 from OSO001.MSG'; say
  105. say SysGetMessage(34, , 'A:', 'the diskette labeled "Disk 2"', 'SER0002')
  106. Say '  (that was just a demonstration.  You do not have to insert a diskette)'
  107. call SysPause
  108.  
  109. /*** Demonstrate SysPutEA ***/
  110. call SysCls
  111. say; say 'Demonstrating SysPutEA...'
  112. call SysPause
  113. call SysSay 'Creating rxtemp.fil...'
  114. call lineout 'rxtemp.fil', 'xyzpdq'
  115. call stream 'rxtemp.fil', 'C', 'CLOSE'
  116. say 'done.'
  117. OS2_rc = SysPutEA('rxtemp.fil', 'REXXUDEM', 'Demonstration of SysPutEA')
  118. If OS2_rc = 0 Then Say 'rxtemp.fil now has an Extended Attribute',
  119.                        'named REXXUDEM.'
  120. Else Say 'We have a problem, the OS/2 file system returned error' OS2_rc
  121. call SysPause
  122.  
  123. /*** Demonstrate SysGetEA ***/
  124. call SysCls
  125. say; say 'Demonstrating SysGetEA...'
  126. OS2_rc = SysGetEA('rxtemp.fil', 'REXXUDEM', 'my_output_variable')
  127. If OS2_rc = 0 Then Do
  128.   Say 'the value of the REXXUDEM Exnded Attribute',
  129.       'is "'my_output_variable'"'
  130.   If my_output_variable == 'Demonstration of SysPutEA' then
  131.     Say '  ...and that is the right value.'
  132.   else Say '  ...but that is the wrong value!'
  133.   End
  134. Else Say 'We have a problem, the OS/2 file system returned error' OS2_rc
  135. call SysPause
  136.  
  137.  
  138. /*** Demonstrate SysFileDelete ***/
  139. call SysCls
  140. say; say 'Demonstrating SysFileDelete by deleting the file rxtemp.fil:'
  141. call SysPause
  142. if SysFileDelete('rxtemp.fil')=0 then
  143.   say 'The file rxtemp.fil has been deleted.'
  144. else
  145.   say 'Could not delete rxtemp.fil!'
  146. call SysPause
  147.  
  148.  
  149. /*** Demonstrate SysFileSearch ***/
  150. call SysCls
  151. say; say 'Demonstrating SysFileSearch:'
  152. say 'About to search the 'bootdrive':\CONFIG.SYS files for'
  153. say 'the word "device":'; say
  154. call SysPause; say
  155. call SysFileSearch 'device', bootdrive':\config.sys', 'file'
  156. say 'Lines found:'; say
  157. do num=1 to file.0
  158.   say file.num
  159. end
  160. say
  161. call SysPause
  162.  
  163.  
  164. /*** Demonstrate SysFileTree ***/
  165. call SysCls
  166. say; say 'Demonstrating SysFileTree by displaying all entries in',
  167.           bootdrive': root subdir:'
  168. call SysPause
  169. call SysFileTree bootdrive':\*', 'files', 'B'
  170. say;
  171. do num=1 to files.0
  172.   say files.num
  173. end
  174. call SysPause
  175.  
  176.  
  177. /*** Demonstrate SysIni ***/
  178. call SysCls
  179. say; say 'Demonstrating SysIni by placing time information in OS2.INI file...'
  180. time=Time()
  181. call SysIni , 'REXXUDEM', 'TIME', time
  182. call SysPause
  183. say; say 'Demonstrating SysIni by retrieving time information from OS2.INI file...'
  184. val = SysIni( , 'REXXUDEM', 'TIME')
  185. say 'The retrieved information = 'val; say
  186. call SysPause
  187. say; say 'Deleting the time information from the OS2.INI file...'
  188. call SysINI , 'REXXUDEM', 'TIME', '$RXDEL'
  189. call SysPause
  190.  
  191.  
  192. /*** Demonstrate SysMkDir ***/
  193. call SysCls
  194. say; say 'Demonstrating SysMkDir:'
  195. say 'RC when trying to create directory',
  196.     bootdrive':\RXTMPDIR = 'SysMkDir(bootdrive':\RXTMPDIR')
  197. call SysPause
  198.  
  199.  
  200. /*** Demonstrate SysRmDir ***/
  201. call SysCls
  202. say; say 'Demonstrating SysRmDir:'
  203. say 'RC when trying to remove directory',
  204.     bootdrive':\RXTMPDIR = 'SysRmDir(bootdrive':\RXTMPDIR')
  205. call SysPause
  206.  
  207.  
  208. /*** Demonstrate SysOS2Ver ***/
  209. call SysCls
  210.  
  211. say; say 'Demonstrating SysOS2Ver'
  212. Say 'You are running OS/2 version 'SysOS2Ver()
  213. call SysPause
  214.  
  215.  
  216. /*** Demonstrate SysSearchPath ***/
  217. call SysCls
  218. say; say 'Demonstrating SysSearchPath by searching for CMD.EXE in PATH:'
  219. call SysPause
  220. say 'Directory containing CMD.EXE is:  'SysSearchPath('PATH', 'cmd.exe')
  221. call SysPause
  222.  
  223.  
  224. /*** Demonstrate SysSleep ***/
  225. call SysCls
  226. say; say 'Demonstrating SysSleep:  Sleeping for 2 seconds...'
  227. call SysSleep '2'
  228. call SysPause
  229.  
  230.  
  231. /*** Demonstrate SysTempFileName ***/
  232. call SysCls
  233. say; say 'Demonstrating SysTempFileName:'; say
  234. say 'Unique file in' bootdrive':\OS2 =',
  235.     SysTempFileName(bootdrive':\OS2\OS2.???'); say
  236. call SysPause
  237.  
  238.  
  239. /*** Demonstrate SysTextScreenRead ***/
  240. call SysCls
  241. say; say 'Demonstrating SysTextScreenRead by reading the entire screen.'; say
  242. do i=0 to 10
  243.  say copies(' ', i*5)'Hello'
  244. end
  245. say
  246. call SysPause 'Press Enter key to read the screen...'
  247. screen = SysTextScreenRead(0, 0)
  248. say 'Screen read.'
  249. call SysPause 'Press Enter key to clear the screen then restore it...'
  250. call SysCls
  251. call SysSay screen
  252. call SysPause
  253.  
  254.  
  255. /*** Demonstrate SysTextScreenSize ***/
  256. call SysCls
  257. say; say 'Demonstrating SysTextScreenSize...'
  258. parse value SysTextScreenSize() with row col
  259. say 'Rows='row', Columns='col
  260. call SysPause
  261.  
  262. /*** Demonstrate SysDropFuncs ***/
  263. call SysCls
  264. say; say 'Demonstrating SysDropFuncs...'
  265. Call SysDropFuncs
  266. Say 'The functions have now been dropped.'
  267.  
  268. say; say 'REXXUDEM demonstration program is complete.'
  269. exit
  270.  
  271.  
  272.  
  273. SysPause:
  274. parse arg prompt
  275.   if prompt='' then
  276.     prompt='Press Enter key when ready . . .'
  277.   call SysSay prompt
  278.   Pull .
  279.   say
  280. return
  281.  
  282.  
  283.  
  284. SysSay:
  285. parse arg string
  286.   call charout 'STDOUT', string
  287. return
  288.