home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / REXMENU2.ZIP / README.CMD < prev    next >
OS/2 REXX Batch file  |  1992-11-25  |  17KB  |  517 lines

  1. /* ReadMe - Introduction to, and example of, RexxMenu.cmd.  This file
  2.  *          is meant to be executed, not necessarily read.  So from the
  3.  *          command line or the desktop run README.CMD.
  4.  *
  5.  * ReadMe uses RexxMenu.dll, and RexxMenu.dll must be available in the
  6.  * current directory.
  7.  */
  8. '@echo off'
  9. /*'mode 80,25'*/
  10.  
  11. 'cls'
  12. say
  13. say '   ReadMe.cmd uses RexxMenu, EnviMenu, and MenuPick as an example of'
  14. say '   how to use these menu utilities.  The menu screens that follow are'
  15. say '   controlled by Rexx- or Envi-menu.'
  16. say
  17. say '   There are two hidden options in this ReadMe.cmd menu.  Type "HID"'
  18. say '   or "SECRET" to find these options.'
  19. say
  20. 'pause'
  21.  
  22. /* For this readme demo, expect RexxMenu.dll to be in the current directory,
  23.  * and so build the file name of the current directory.
  24.  */
  25. RexxMenuDLLSpec = DIRECTORY()
  26. if \(LENGTH(RexxMenuDLLSpec) = 3) then RexxMenuDLLSpec = INSERT(RexxMenuDLLSpec,'\')
  27. RexxMenuDLLSpec = INSERT(RexxMenuDLLSpec,'RexxMenu.dll')
  28. CALL RxFuncAdd 'SysFileTree', 'rexxutil', 'SysFileTree'
  29. CALL SysFileTree RexxMenuDLLSpec, 'FileList' , 'OF'
  30. if FileList.0 = 0 then do
  31.    DROP FileList.
  32.    say ''
  33.    say '   Readme.cmd needs "RexxMenu.dll" in the current directory.'
  34.    say
  35.    'pause'
  36.    EXIT
  37. end  /* Do */
  38. DROP FileList.
  39.  
  40. /* Try oh try to register the RexxMenu Function */
  41. CALL RxFuncDrop 'RexxMenu'
  42. CALL RxFuncAdd 'RexxMenu', RexxMenuDLLSpec, 'RexxMenu'
  43.  
  44. /* Until the user quits, allow them to pick readme choices */
  45. RememberCurDir = DIRECTORY()
  46. MenuChoice = ''
  47. DO FOREVER
  48.    CALL Directory RememberCurDir
  49.    MenuChoice = RexxMenu('ReadMe.cmd','/Suf','.:','/Com','/* ',,
  50.                          '/Init',MenuChoice,'/Hid','_SECRET_',,
  51.                          '/Prompt','Select a RexxMenu topic:')
  52.    if 0 = COMPARE(MenuChoice,'') then signal Quit.
  53.    interpret 'CALL' INSERT(MenuChoice,'.');
  54. end /* do */
  55. EXIT
  56.  
  57.  
  58. /**********************************************************************/
  59. /* WHAT FOLLOWS IS A LIST OF FUNCTIONS THAT README.CMD CAN ACCESS     */
  60. /**********************************************************************/
  61.  
  62. View.RexxMenu.User.Document.:
  63. /* Read the document for how to use RexxMenn in your REXX language programs
  64.  */
  65. 'attrib RexxMenu.doc +r'
  66. 'e.exe RexxMenu.doc'
  67. RETURN
  68.  
  69. RexxMenuHelp.:
  70. /* View help information (RexxMenuHelp) from the RexxMenu dll
  71.  */
  72. CALL RxFuncDrop 'RexxMenuHelp'
  73. CALL RxFuncAdd 'RexxMenuHelp', RexxMenuDLLSpec, 'RexxMenuHelp'
  74. 'mode 80,50'
  75. call RexxMenuHelp
  76. 'mode 80,25'
  77. CALL RxFuncDrop 'RexxMenuHelp'
  78. RETURN
  79.  
  80. EnviMenu.:
  81. /* Descripton of EnviMenu: RexxMenu wrapper for the REXXaphobic
  82.  */
  83. 'cls'
  84. say
  85. say 'EnviMenu - A shell for calling RexxMenu from the command line or from a .cmd'
  86. say '           batch file.  EnviMenu sets an environment variable from a menu.'
  87. say
  88. say 'SYNTAX: EnviMenu <ENVIRONMENT_VARIABLE> <FileSpec> [RexxMenu Options...]'
  89. say 'Where:'
  90. say '  ENVIRONMENT_VARIABLE - This environment variable will be set to the chosen'
  91. say '           menu option.  Same as the <Choice> option in RexxMenu().'
  92. say '  FileSpec - Same as the <File> argument in RexxMenu().'
  93. say '  RexxMenu Options - Options can be added the same as they are in RexxMenu(),'
  94. say '           but there should not be commas between options, but spaces.'
  95. say
  96. say 'Example: To set environment variable CHOICE from the options "Yes",'
  97. say '         "No", and "Not Sure yet" listed in the file OPTIONS, enter the'
  98. say '         following at the command line or call from a batch file:'
  99. say '            EnviMenu CHOICE options /Prompt "Are you ready to rock?" /Init Yes'
  100. say
  101. 'pause'
  102. RETURN
  103.  
  104. MenuPick.:
  105. /* Descripton of MenuPick: another RexxMenu wrapper for the REXXaphobic
  106.  */
  107. 'cls'
  108. 'call MenuPick'
  109. 'pause'
  110. RETURN
  111.  
  112. Examples.:
  113. /* Test and view sample .CMD files that demonstrate some uses of RexxMenu
  114.  */
  115. ExampleChoice = ''
  116. do until ExampleChoice = ''
  117.    CALL Directory RememberCurDir
  118.    ExampleChoice = RexxMenu('ReadMe.cmd','/Suf','.Example:','/Com','/* ',,
  119.                             '/Init',ExampleChoice,'/Esc','/Sort',,
  120.                             '/Prompt','Select Example to Run or View (Esc to quit)')
  121.    if \(ExampleChoice = '') then
  122.       interpret 'CALL' INSERT(ExampleChoice,'.Example');
  123. end /* do */
  124. RETURN
  125.  
  126.  
  127. Install.:
  128. /* Copy RexxMenu.dll to a directory from your LIBPATH variable in C:\CONFIG.SYS
  129.  */
  130. /* Make sure that C:\CONFIG.SYS exists */
  131. 'cls'
  132. InstallFail = 1   /* assume it failed to install */
  133. CALL SysFileTree 'C:\CONFIG.SYS', 'FileList' , 'OF'
  134. if 0 = FileList.0 then do
  135.    say '  Could not find C:\CONFIG.SYS to get value of LIBPATH.'
  136. end  /* Do */
  137. else do
  138.    /* Read the LIBPATH line from CONFIG.SYS */
  139.    LibPath = RexxMenu('C:\CONFIG.SYS','/Time','0','/Prompt','NONE',,
  140.                       '/Pre','LIBPATH')
  141.    'cls'
  142.    /* Skip all spaces and '=' at the beginning of LibPath */
  143.    do while \(LibPath = '') & (LEFT(LibPath,1) = '' | LEFT(LibPath,1) = '=')
  144.       LibPath = RIGHT(LibPath,LENGTH(LibPath)-1)
  145.    end /* do */
  146.    if LibPath = '' then do
  147.       say '  Could not get a value for LIBPATH from C:\CONFIG.SYS.'
  148.    end  /* Do */
  149.    else do
  150.       /* Create File with one entry for each element of LibPath, but only those
  151.        * elements which are, or nearly are, absolute directories
  152.        */
  153.       'if exist PathMenu.tmp del PathMenu.tmp'
  154.       OptionCount = 0
  155.       do until Dir = ''
  156.          PARSE VAR LibPath Dir ';' LibPath
  157.          if Dir = '' then Dir = LibPath
  158.          if \(Dir = '') then do
  159.             if LEFT(Dir,1) = '\' | (2 < LENGTH(Dir) & SUBSTR(Dir,2,2) = ':\') then do
  160.                'echo' Dir '>> PathMenu.tmp'
  161.                OptionCount = OptionCount + 1
  162.             end  /* Do */
  163.          end  /* Do */
  164.       end /* do */
  165.       if OptionCount = 0 then do
  166.          say '  Found no absolute directories to install to in LIBPATH of C:\CONFIG.SYS'
  167.       end  /* Do */
  168.       else do
  169.          Dir = RexxMenu('PathMenu.tmp','/Esc','/Sort',,
  170.                         '/Prompt','Select Directory to install RexxMenu.dll to (Esc to quit)')
  171.          'if exist PathMenu.tmp del PathMenu.tmp'
  172.          'cls'
  173.          if Dir = '' then do
  174.             say '  RexxMenu.dll was not installed in any directory'
  175.             InstallFail = 0
  176.          end /* Do */
  177.          else do
  178.             /* Put a backslash at the end of dir if it doesn't have one alread */
  179.             if \('\' = RIGHT(DIR,1)) then DIR = INSERT(DIR,'\')
  180.             'if exist' INSERT(Dir,'RexxMenu.dll') 'attrib' INSERT(Dir,'RexxMenu.dll') '-r -s -h'
  181.             'copy RexxMenu.dll' INSERT(Dir,'RexxMenu.dll')
  182.             /* Test that it seems to have been copied there */
  183.             CALL SysFileTree INSERT(Dir,'RexxMenu.dll'),'FindFile','F'
  184.             if FindFile.0 = 0 then do
  185.                say '  Tried to copy RexxMenu.dll to' INSERT(Dir,'RexxMenu.dll')
  186.                say '  but it does not seem to have worked.'
  187.             end  /* Do */
  188.             else do
  189.                say '  RexxMenu.dll has been installed in your chosen LIBPATH directory.'
  190.                say '  It should now be available in REXX files anywhere.'
  191.                InstallFail = 0
  192.             end  /* Do */
  193.          end  /* Do */
  194.       end  /* Do */
  195.    end  /* Do */
  196. end  /* Do */
  197. if InstallFail = 1 then do
  198.    say ''
  199.    say '  Automatic installation was unsuccesful.  Please copy RexxMenu.dll'
  200.    say '  into one of the directories in your LIBPATH variable.'
  201. end  /* Do */
  202. say
  203. 'pause'
  204. DROP FileList.
  205.  
  206. /* DO NEARLY THE SAME INSTALLATION FOR UTILITY FILES INTO PATH PLACES */
  207. InstallFail = 1
  208. 'set MP_PROMPT=Install EnviMenu and MenuPick utilities?'
  209. 'call MenuPick MP_INSTALL Yes:Yes, install into a selected PATH directory.;No:No, do not install.'
  210. if value('MP_INSTALL',,'OS2ENVIRONMENT') = 'Yes' then do
  211.    /* Use LIBPATH as the PATH environment variable */
  212.    LibPath = value('PATH',,'OS2ENVIRONMENT')
  213.    'cls'
  214.    /* Skip all spaces and '=' at the beginning of LibPath */
  215.    do while \(LibPath = '') & (LEFT(LibPath,1) = '' | LEFT(LibPath,1) = '=')
  216.       LibPath = RIGHT(LibPath,LENGTH(LibPath)-1)
  217.    end /* do */
  218.    if LibPath = '' then do
  219.       say '  Could not get a value for the PATH environment variable.'
  220.    end  /* Do */
  221.    else do
  222.       /* Create File with one entry for each element of LibPath, but only those
  223.        * elements which are, or nearly are, absolute directories
  224.        */
  225.       'if exist PathMenu.tmp del PathMenu.tmp'
  226.       OptionCount = 0
  227.       do until Dir = ''
  228.          PARSE VAR LibPath Dir ';' LibPath
  229.          if Dir = '' then Dir = LibPath
  230.          if \(Dir = '') then do
  231.             if LEFT(Dir,1) = '\' | (2 < LENGTH(Dir) & SUBSTR(Dir,2,2) = ':\') then do
  232.                'echo' Dir '>> PathMenu.tmp'
  233.                OptionCount = OptionCount + 1
  234.             end  /* Do */
  235.          end  /* Do */
  236.       end /* do */
  237.       if OptionCount = 0 then do
  238.          say '  Found no absolute directories to install to in PATH environment variable.'
  239.       end  /* Do */
  240.       else do
  241.          Dir = RexxMenu('PathMenu.tmp','/Esc','/Sort',,
  242.                         '/Prompt','Select PATH Directory to install EnviMenu and MenuPick (Esc to quit)')
  243.          'if exist PathMenu.tmp del PathMenu.tmp'
  244.          'cls'
  245.          if Dir = '' then do
  246.             say '  Utilities were not installed in any directory'
  247.             InstallFail = 0
  248.          end /* Do */
  249.          else do
  250.             /* Put a backslash at the end of dir if it doesn't have one alread */
  251.             if \('\' = RIGHT(DIR,1)) then DIR = INSERT(DIR,'\')
  252.             'if exist' INSERT(Dir,'EnviMenu.cmd') 'attrib' INSERT(Dir,'EnviMenu.cmd') '-r -s -h'
  253.             'if exist' INSERT(Dir,'MenuPick.cmd') 'attrib' INSERT(Dir,'MenuPick.cmd') '-r -s -h'
  254.             'copy EnviMenu.cmd' INSERT(Dir,'EnviMenu.cmd')
  255.             'copy MenuPick.cmd' INSERT(Dir,'MenuPick.cmd')
  256.             /* Test that it seems to have been copied there */
  257.             CALL SysFileTree INSERT(Dir,'EnviMenu.cmd'),'FindFile','F'
  258.             if \(FindFile.0 = 0) then
  259.                CALL SysFileTree INSERT(Dir,'MenuPick.cmd'),'FindFile','F'
  260.             if FindFile.0 = 0 then do
  261.                say '  Tried to copy EnviMenu.cmd and MenuPick.cmd to' Dir
  262.                say '  but it does not seem to have worked.'
  263.             end  /* Do */
  264.             else do
  265.                say '  EnviMenu.cmd and MenuPick.cmd have been installed in your chosen'
  266.                say '  PATH directory.'
  267.                InstallFail = 0
  268.             end  /* Do */
  269.          end  /* Do */
  270.       end  /* Do */
  271.    end  /* Do */
  272. end  /* Do */
  273. if InstallFail = 1 then do
  274.    say ''
  275.    say '  Automatic installation was unsuccesful.  Please copy EnviMenu.cmd'
  276.    say '  and MenuPick.cmd into one of the directories in your PATH.'
  277. end  /* Do */
  278. say
  279. 'pause'
  280. RETURN
  281.  
  282. Register.:
  283. /* RexxMenu is shareware. Select this option to PRINT a registration form.
  284.  */
  285. 'cls'
  286. say
  287. say '              Attempting to print Register.FRM...'
  288. say
  289. say '  If this is unsuccesful then please print the file Register.FRM'
  290. say '  in whatever way you normally print text.  Or, read the Register.FRM'
  291. say '  and send the information contained in that form along with your'
  292. say '  shareware-level payment ($5 for clean conscience, $10 for'
  293. say '  registration, updates, and support) to:'
  294. say
  295. say '      Brent Noorda'
  296. say '      36 Tainter Street'
  297. say '      Medford, MA  02155'
  298. say '      USA'
  299. say
  300. say
  301. say 'print Register.FRM'
  302. say
  303. 'print Register.FRM'
  304. 'pause'
  305. RETURN
  306.  
  307. Quit.:
  308. /* Quit ReadMe.cmd, and return to the OS/2 prompt
  309.  */
  310. CALL RxFuncDrop 'RexxMenu'
  311. 'cls'
  312. say
  313. say '  If you enjoy using this shareware product, then please do not forget'
  314. say '  to register.  See the "Register" option from the ReadMe.cmd menu, or'
  315. say '  print and fill out the "Register.FRM" file.'
  316. say
  317. /* ADD RexxMenu function support from the RexxMenu.dll */
  318. CALL RxFuncAdd 'SysSleep', 'rexxutil', 'SysSleep'
  319. CALL SysSleep 5
  320. say
  321. say
  322. '@pause'
  323. EXIT
  324.  
  325. _SECRET_Hid.:
  326. 'cls'
  327. say
  328. say '   Congratulations.  You found a hidden menu option and all you got was this'
  329. say '   lousy message.'
  330. say
  331. 'pause'
  332. RETURN
  333.  
  334. _SECRET_Secret.:
  335. 'cls'
  336. say
  337. say
  338. say '    When law has been outlawed, only outlaws will be lawyers.'
  339. say
  340. say
  341. 'pause'
  342. RETURN
  343.  
  344.  
  345. /**********************************************************************/
  346. /* WHAT FOLLOWS IS A LIST OF FUNCTIONS THAT ARE ACCESSED FROM THE     */
  347. /* EXAMPLES PORTION OF README.CMD                                     */
  348. /**********************************************************************/
  349.  
  350. ViewInfo....Run.Example:
  351. /* Demonstration program to choose from known list of *.INF file to view
  352.  */
  353. CALL ViewInfo.cmd
  354. RETURN
  355.  
  356. ViewInfo....View.Example:
  357. /* View the ViewInfo.cmd demonstration command file
  358.  */
  359. 'attrib ViewInfo.cmd +r'
  360. 'e.exe ViewInfo.cmd'
  361. RETURN
  362.  
  363. CDMenu....Run.Example:
  364. /* Demonstrate RexxMenu by interactively choosing directory to change to
  365.  */
  366. CALL CDMenu.cmd
  367. '@cls'
  368. '@cd'
  369. say
  370. say '  You have used CDMenu to move to a different directory.'
  371. say '  Big thrill.'
  372. say
  373. 'pause'
  374. RETURN
  375.  
  376. CDMenu....View.Example:
  377. /* View the CDMenu.cmd demonstration script
  378.  */
  379. 'attrib CDMenu.cmd +r'
  380. 'e.exe CDMenu.cmd'
  381. RETURN
  382.  
  383. AttrMenu....Run.Example:
  384. /* Demonstrate AttrMenu to selectively set, then unset, the archive bit
  385.  */
  386. '@cls'
  387. CALL AttrMenu
  388. say
  389. 'pause'
  390. say
  391. say '  About to remove archive attribute on chosen files in this directory.'
  392. say
  393. say '  From the command line, this would be: "AttrMenu * -a" or "AttrMenu -a"'
  394. say
  395. 'pause'
  396. CALL AttrMenu '-a'
  397. 'pause'
  398. '@cls'
  399. say
  400. say '  About to set archive attribute on chosen files in this directory.'
  401. say
  402. say '  From the command line, this would be: "AttrMenu * +a" or "AttrMenu +a"'
  403. say
  404. 'pause'
  405. CALL AttrMenu '+a'
  406. 'pause'
  407. RETURN
  408.  
  409. AttrMenu....View.Example:
  410. 'attrib AttrMenu.cmd +r'
  411. 'e.exe AttrMenu.cmd'
  412. RETURN
  413.  
  414. VInfoAll....Run.Example:
  415. /* Select to view from list of all *.INF files on this disk
  416.  */
  417. '@cls'
  418. CALL VInfoAll.cmd
  419. RETURN
  420.  
  421. VInfoAll....View.Example:
  422. /* View the VInfoAll.cmd demonstration file
  423.  */
  424. 'attrib VInfoAll.cmd +r'
  425. 'e.exe VInfoAll.cmd'
  426. RETURN
  427.  
  428. QuikMenR....Run.Example:
  429. /* Run sample program for accessing common functions using RexxMenu
  430.  */
  431. '@cls'
  432. say
  433. say '  This is a sample of a REXX program, which you might want to'
  434. say '  put on your desktop, for quickly accessing your commonly used'
  435. say '  programs or command files.  With a couple of keystrokes or'
  436. say '  mouse-clicks your menu-chosen function is up and running.'
  437. say
  438. say '  I use QuikMenR many times a day, and this is the primary'
  439. say '  reason why I created RexxMenu. This sample is taken from my'
  440. say '  own desktop, and so not all of the options will work on your'
  441. say '  system: they may rely on my particular configuration,'
  442. say '  program-set, and paths.  QuikMenR can be easily modified for'
  443. say '  your own frequently-used functions.'
  444. say
  445. '@pause'
  446. CALL QuikMenR.cmd
  447. 'mode 80,25'
  448. RETURN
  449.  
  450. QuikMenR....View.Example:
  451. /* View the QuikMenR.cmd example file
  452.  */
  453. 'attrib QuikMenR.cmd +r'
  454. 'e.exe QuikMenR.cmd'
  455. RETURN
  456.  
  457. QuikMenE....Run.Example:
  458. /* Run sample program for accessing common functions using EnviMenu
  459.  */
  460. '@cls'
  461. say
  462. say '  This is a sample of batch file using EnviMenu.  It is much the'
  463. say '  as the QuikMenR example, but uses a batch file instead of a REXX'
  464. say '  file.  This is done by calling EnviMenu.cmd, which is a shell around'
  465. say '  RexxMenu for those who do not want to know they are using REXX.'
  466. say
  467. say '  This is a sample of a batch file, which you might want to'
  468. say '  put on your desktop, for quickly accessing your commonly used'
  469. say '  programs or command files.  With a couple of keystrokes or'
  470. say '  mouse-clicks your menu-chosen function is up and running.'
  471. say
  472. say '  I use QuikMenR many times a day, and this is the primary'
  473. say '  reason why I created RexxMenu. This sample is taken from my'
  474. say '  own desktop, and so not all of the options will work on your'
  475. say '  system: they may rely on my particular configuration,'
  476. say '  program-set, and paths.  QuikMenR can be easily modified for'
  477. say '  your own frequently-used functions.'
  478. say
  479. '@pause'
  480. 'CALL QuikMenE.cmd'
  481. 'mode 80,25'
  482. RETURN
  483.  
  484. QuikMenE....View.Example:
  485. /* View the QuikMenE.cmd example file
  486.  */
  487. 'attrib QuikMenE.cmd +r'
  488. 'e.exe QuikMenE.cmd'
  489. RETURN
  490.  
  491. Solitaire....Run.Example:
  492. /* Run sample that uses RexxMenu to save KLONDIKE configuration for different users
  493.  */
  494. CALL Solitair.cmd
  495. RETURN
  496.  
  497. Solitaire....View.Example:
  498. /* View the Solitair.cmd example file
  499.  */
  500. 'attrib Solitair.cmd +r'
  501. 'e.exe Solitair.cmd'
  502. RETURN
  503.  
  504. Prompts....Run.Example:
  505. /* Uses the MenuPick.cmd utility to select Command Processor sessions
  506.  */
  507. 'CALL Prompts.cmd'
  508. RETURN
  509.  
  510. Prompts....View.Example:
  511. /* view Prompts.cmd, which uses the MenuPick utility
  512.  */
  513. 'attrib Prompts.cmd +r'
  514. 'e.exe Prompts.cmd'
  515. RETURN
  516.  
  517.