home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / apmt34.zip / APMTSAMP.CMD < prev    next >
OS/2 REXX Batch file  |  1994-07-07  |  5KB  |  145 lines

  1. /******************************************************************/
  2. /* Sample APMT client program                                     */
  3. /******************************************************************/
  4. /* This program works on the PMSEEK (Seek and Scan Files) utility */
  5. /* provided with OS/2 2.x. To run this PMSEEK.EXE should be in    */
  6. /* the PATH.                                                      */
  7. /* Note as a side effect of running this sample, a file may  be   */
  8. /* printed and a file APMTJUNK may  be created in the current     */
  9. /* directory.                                                     */
  10. /******************************************************************/
  11.  
  12. /******************************************************************/
  13. /* Part 1: sample common prefix for APMT programs                 */
  14. /******************************************************************/
  15. Trace off
  16. call APMT_INIT
  17. /******************************************************************/
  18. /* Part 2: unique for each APMT program                           */
  19. /******************************************************************/
  20. /* start the PMSEEK program if not already started */
  21. say "APMT Session started successfully"
  22. say "Selecting PMSEEK window           "
  23. rc = SELECT_WINDOW("PMSEEK*","10")
  24. if rc > 0 then do
  25.    say "PMSEEK not found.. starting PMSEEK.EXE "
  26.    rc = START_PROGRAM("PMSEEK.EXE")
  27.    if rc > 0 then do
  28.       say "Program could not be started"
  29.       signal errorexit
  30.       end
  31.       else Program_started = 1;
  32.    rc = SELECT_WINDOW("PMSEEK*","50")
  33.    end
  34. say "PMSEEK window selected"
  35. say "Setting search criteria on PMSEEK"
  36. /* Set filename search criterion */
  37. rc = ENTRYFIELD_SET_TEXT("1","CONFIG.*")
  38. /* Set search text criterion */
  39. rc = ENTRYFIELD_SET_TEXT("2","SWAPPATH")
  40. /* set 'editor' to "E3" */
  41. rc = ENTRYFIELD_SET_TEXT("3","E3.EXE")
  42.  
  43. /* Ensure sub-directory search */
  44. rc = MENU_QUERY_STATE("Options", "Search subdirectories", "st")
  45. if st.1 \= "CHECKED" then do
  46.    say ' Setting subdirectory search option'
  47.    rc = MENU_SELECT("Options", "Search subdirectories")
  48.    end
  49.  
  50. /* search only the C drive */
  51.  /* First uncheck all checkboxes                  */
  52.  rc = CHECKBOX_QUERY_ALL("cbox")
  53.  do i = 1 to cbox.0
  54.     rc = CHECKBOX_QUERY_STATE(cbox.i,"state")
  55.     if (state.1 = "CHECKED") then
  56.        rc = CHECKBOX_CLICK(cbox.i)
  57.     end
  58.  /* Now check C            */
  59.  rc = CHECKBOX_CLICK("C")
  60.  
  61. say "Clearing the previous list       "
  62. /* Clear the list first, by using mnemonic keys */
  63. rc = KEYBOARD("e","A")
  64. rc = KEYBOARD("l")
  65.  
  66. /* press the search button */
  67. say "Beginning Search.                "
  68. rc = PUSHBUTTON_CLICK("Search")
  69.  
  70. /* wait for search to complete */
  71. rc = WAIT(500)       /* enough time to clear status from any prior search*/
  72. rc = TEXT_QUERY_TEXT("5", "status")    /* we know status is the 5th field*/
  73. parse var status . w2 .
  74. do while w2 \= "Complete..."
  75.    rc = TEXT_QUERY_TEXT("5", "status")
  76.    parse var status . w2 .
  77.    end
  78.  
  79. say "Search completed. Print First File"
  80. /* print the first file in the list                                      */
  81. rc = LISTBOX_QUERY_COUNT("1","items")
  82. if items > 0 then do
  83.   rc = LISTBOX_SELECTITEM("1","0")
  84.   rc = KEYBOARD("s","A")
  85.   rc = KEYBOARD("c")
  86.   rc = SELECT_DIALOGWINDOW("File Command","50")
  87.   rc = ENTRYFIELD_SET_TEXT("1","print /")
  88.   rc = KEYBOARD("ENTER")
  89.   end
  90.  
  91. say "Saving the file list"
  92. /* Save the file list                                                    */
  93. /* Allow time for modal dialog box to clear */
  94. rc = SELECT_DIALOGWINDOW("File Command")
  95. do while rc = 0
  96.    rc = WAIT(200)
  97.    rc = SELECT_DIALOGWINDOW("File Command")
  98.    end
  99.  
  100. rc = SELECT_WINDOW("PMSEEK*")
  101. rc = MENU_SELECT("~File","Save ~as...")
  102. rc = SELECT_DIALOGWINDOW("Save As","50")
  103. rc = ENTRYFIELD_SET_TEXT("1","APMTJUNK")
  104. rc = PUSHBUTTON_CLICK("Save")
  105. rc = SELECT_DIALOGWINDOW("*",20)
  106. rc = KEYBOARD("ENTER")  /* This cancels the message box from save  */
  107.  
  108. say "Quitting ..."
  109. /* All done; If the program was started by this exec, terminate it */
  110. if Program_started = 1 then do;
  111.    rc = SELECT_WINDOW("PMSEEK*")
  112.    rc = SYSMENU_SELECT("Close")
  113.    end
  114.  
  115. /******************************************************************/
  116. /* Part 3: common suffix for all APMT programs                    */
  117. /******************************************************************/
  118. APMT_CLOSE:
  119. rc = END_SESSION();
  120. /******************************************************************/
  121. errorexit:
  122. exit
  123.  
  124. DropFUNC:
  125.  call APMTDropFuncs;
  126.  call rxfuncdrop(APMTDropFuncs)
  127. return
  128.  
  129. APMT_INIT:
  130. call rxfuncadd  'APMTLoadFuncs',  'apmtext', 'APMTLoadFuncs'  /* entry points from the DLL    */
  131. call APMTLoadFuncs;
  132. rc = INIT_SESSION();
  133. if rc \= 0
  134.    then do
  135.      say apmtmsg
  136.      exit
  137.      end
  138. signal on error name  APMT_CLOSE
  139. if apmtver.client \= apmtver.server then
  140.    say 'WARNING: Version mismatch. Client ='apmtver.client 'Server ='apmtver.server
  141.    else say 'Running APMT version 'apmtver.client
  142. signal on halt name APMT_CLOSE
  143. return
  144.  
  145.