home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / os2ff101.zip / os2ff.VRX < prev    next >
Text File  |  1993-08-12  |  10KB  |  446 lines

  1. /*:VRX         Main
  2. */
  3. /*  Main
  4. */
  5. Main:
  6. /*  Process the arguments.
  7.     Get the parent window.
  8. */
  9.     parse source . calledAs .
  10.     parent = ""
  11.     argCount = arg()
  12.     argOff = 0
  13.     if( calledAs \= "COMMAND" )then do
  14.         if argCount >= 1 then do
  15.             parent = arg(1)
  16.             argCount = argCount - 1
  17.             argOff = 1
  18.         end
  19.     end
  20.     InitArgs.0 = argCount
  21.     if( argCount > 0 )then do i = 1 to argCount
  22.         InitArgs.i = arg( i + argOff )
  23.     end
  24.     drop calledAs argCount argOff
  25.  
  26. /*  Load the windows
  27. */
  28.     call VRInit
  29.     parse source . . spec
  30.     _VREPrimaryWindowPath = ,
  31.         VRParseFileName( spec, "dpn" ) || ".VRW"
  32.     _VREPrimaryWindow = ,
  33.         VRLoad( parent, _VREPrimaryWindowPath )
  34.     drop parent spec
  35.     if( _VREPrimaryWindow == "" )then do
  36.         call VRMessage "", "Cannot load window:" VRError(), ,
  37.             "Error!"
  38.         _VREReturnValue = 32000
  39.         signal _VRELeaveMain
  40.     end
  41.  
  42. /*  Process events
  43. */
  44.     call Init
  45.     signal on halt
  46.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  47.         _VREEvent = VREvent()
  48.         interpret _VREEvent
  49.     end
  50. _VREHalt:
  51.     _VREReturnValue = Fini()
  52.     call VRDestroy _VREPrimaryWindow
  53. _VRELeaveMain:
  54.     call VRFini
  55. exit _VREReturnValue
  56.  
  57. VRLoadSecondary: procedure
  58.     name = arg( 1 )
  59.  
  60.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  61.     call VRMethod window, "CenterWindow"
  62.     call VRSet window, "Visible", 1
  63.     call VRMethod window, "Activate"
  64. return window
  65.  
  66. /*:VRX         About_OK_Click
  67. */
  68. About_OK_Click:
  69.     Call VRSet "About_OS2FF","Visible",0
  70. return/*:VRX         About_OS2FF_Close
  71. */
  72. About_OS2FF_Close:
  73.     window = VRInfo( "Object" )
  74.     call VRDestroy window
  75.     drop window
  76. return
  77. /*:VRX         Do_Search
  78. */
  79. Do_Search:
  80.  
  81. if search_active = 1 then return
  82.  
  83. search_active = 1
  84.  
  85. count = 0
  86.  
  87. search_for = strip(VRGet("Search_For","Value"))
  88.  
  89. if  length(search_for) = 0 then do
  90.     call VRSet VRWindow(),"StatusText","You must specify something to search for"
  91.     search_active = 0
  92.     return
  93.     end
  94.  
  95. x = VRMethod("data_list","Reset")
  96.  
  97. stat_opt = null
  98.  
  99. call set_status
  100.    
  101. drop data.
  102.  
  103. Select 
  104.     When sort_type = "Ascend" then 
  105.         Call VRSet  "Data_List","Sort","Ascending"
  106.     When sort_type = "Descend" then
  107.        Call VRSet  "Data_List","Sort","Descending"
  108.     When sort_type = "None" then
  109.        Call VRSet  "Data_List","Sort","None"
  110.     end
  111.  
  112. Select
  113.     When search_Method = "Path" then
  114.         do  i = 1 to path.0
  115.             call set_status path.i
  116.             x = SysFileTree(path.i"\"search_for,"data.","F")
  117.             if data.0 = 0 then iterate
  118.             call fix_up_data
  119.             x = VRMethod("data_list","AddStringList","data.")
  120.             drop data.
  121.             end
  122.     When search_Method = "Dpath" then
  123.         do  i = 1 to dpath.0
  124.             call set_status dpath.i
  125.             x = SysFileTree(dpath.i"\"search_for,"data.","F")
  126.             if data.0 = 0 then iterate
  127.             call fix_up_data
  128.             x = VRMethod("data_list","AddStringList","data.")
  129.             drop data.
  130.             end
  131.     When search_Method = "Libpath" then
  132.         do  i = 1 to libpath.0
  133.             call set_status libpath.i
  134.             x = SysFileTree(libpath.i"\"search_for,"data.","F")
  135.             if data.0 = 0 then iterate
  136.             call fix_up_data
  137.             x = VRMethod("data_list","AddStringList","data.")
  138.             drop data.
  139.             end
  140.     When left(search_Method,3) = "Any" then do
  141.         if search_method = "AnyLocal" then 
  142.            Used_Disks = SysDriveMap('C:',"LOCAL")
  143.         else Used_Disks = SysDriveMap('C:')
  144.         drives = words(used_disks)
  145.         do  i = 1 to drives
  146.             drive = word(used_disks,i)
  147.             call set_status drive
  148.             x = SysFileTree(drive"\"search_for,"data.","FS")
  149.             if data.0 = 0 then iterate
  150.             call fix_up_data
  151.             x = VRMethod("data_list","AddStringList","data.")
  152.             drop data.
  153.             end
  154.         end
  155.     otherwise nop;
  156.     end
  157.  
  158. call VRSet VRWindow(),"StatusText","Search Complete for" search_for "using" search_method "with" count "hits"
  159.  
  160. search_active = 0 
  161.  
  162. return
  163.  
  164. Fix_Up_Data:
  165. count = count + data.0
  166. do ix = 1 to data.0
  167.    parse value data.ix with date time size attr file
  168.    name = VRParseFileName(file,"NE")
  169.    drive = VRParseFileName(file,"d")
  170.    path  = VRParseFileName(file,"p")
  171.    data.ix = name drive":"path date time size attr
  172.    end
  173. return
  174.  
  175. Set_Status:
  176. arg stat_opt
  177. call VRSet VRWindow(),"StatusText","Performing Search for" search_for "using" search_method stat_opt
  178. return/*:VRX         Fini
  179. */
  180. Fini:
  181.     window = VRWindow()
  182.     call VRSet window, "Visible", 0
  183.     drop window
  184. return 0
  185.  
  186. /*:VRX         Halt
  187. */
  188. Halt:
  189.     signal _VREHalt
  190. return
  191.  
  192. /*:VRX         Init
  193. */
  194. Init:
  195.  
  196.     call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  197.     call SysLoadFuncs
  198.  
  199.     report = "C:\find.rpt"
  200.  
  201.     Current_Dir =  VRCurrDrive()""VRCurrDir()
  202.  
  203.     call VRSet VRWindow(),"Caption","OS/2 Find File from: ",
  204.        current_dir
  205.  
  206.     config_sys = "c:\config.sys"
  207.  
  208.     parse value "" with null path. libpath. dpath.
  209.     parse value "0 0 0 0 0" with path.0 libpath.0 dpath. hit search_active
  210.  
  211.     do    until lines(config_sys) = 0
  212.        if hit = 3 then leave
  213.     data = translate(linein(config_sys))
  214.     select
  215.         when left(data,9)  = "SET PATH="    then call set_path
  216.            when left(data,10) = "SET DPATH="    then call set_dpath
  217.         when left(data,8)  = "LIBPATH="           then call set_libpath
  218.         otherwise nop;
  219.         end
  220.     end
  221.  
  222.     call lineout config_sys
  223.  
  224.     window = VRWindow()
  225.     call VRMethod window, "CenterWindow"
  226.     call VRSet window, "Visible", 1
  227.     call VRMethod window, "Activate"
  228.     drop window
  229.  
  230.     Call VRLoad VRWindow(), VRWindowPath(),"About_OS2FF"
  231.     Call VRSet "About_OS2FF","Visible",0
  232.  
  233. sort_type     = "None"
  234. search_method = "AnyLocal"
  235.  
  236. return
  237.  
  238. set_path:
  239.     path  = translate(substr(data,10),' ',';')
  240.     pathw = words(path)
  241.     hit = hit + 1
  242.     do    i = 1 to pathw
  243.     c = path.0 + 1
  244.     path.c = word(path,i)
  245.     if right(path.c,1) = "\" then do
  246.        len = length(path.c)
  247.        path.c = left(path.c,len-1)
  248.        end
  249.     path.0 = c
  250.     end
  251.     return
  252.  
  253. set_libpath:
  254.     hit = hit + 1
  255.     libpath  = translate(substr(data,9),' ',';')
  256.     libpathw = words(libpath)
  257.     do    i = 1 to libpathw
  258.     c = libpath.0 + 1
  259.     libpath.c = word(libpath,i)
  260.     if right(libpath.c,1) = "\" then do
  261.        len = length(libpath.c)
  262.        libpath.c = left(libpath.c,len-1)
  263.        end
  264.  
  265.     libpath.0 = c
  266.     end
  267.     return
  268.  
  269. set_dpath:
  270.     hit = hit + 1
  271.     dpath = translate(substr(data,11),' ',';')
  272.     dpathw = words(dpath)
  273.     do    i = 1 to dpathw
  274.     c = dpath.0 + 1
  275.     dpath.c = word(dpath,i)
  276.     if right(dpath.c,1) = "\" then do
  277.        len = length(dpath.c)
  278.        dpath.c = left(dpath.c,len-1)
  279.        end
  280.     dpath.0 = c
  281.     end
  282.     return/*:VRX         Menu_About_Click
  283. */
  284. Menu_About_Click:
  285.  
  286.    Call VRSet "About_OS2FF","Visible",1
  287.  
  288. return
  289.  
  290. /*:VRX         Menu_Exit_Click
  291. */
  292. Menu_Exit_Click:
  293.  
  294. Call VRSet VRWindow(),"Shutdown",1
  295.  
  296. return
  297.  
  298. /*:VRX         Menu_Path_Anylocal_Click
  299. */
  300. Menu_Path_Anylocal_Click:
  301.  
  302. search_method = "AnyLocal"
  303.  
  304. call do_search
  305.  
  306. return
  307.  
  308. /*:VRX         Menu_path_anywhere_Click
  309. */
  310. Menu_path_anywhere_Click:
  311.  
  312. search_method = "Anywhere"
  313.  
  314. call do_search
  315.  
  316. return
  317.  
  318. /*:VRX         Menu_path_dpath_Click
  319. */
  320. Menu_path_dpath_Click:
  321.  
  322. search_method = "Dpath"
  323.  
  324. call do_search
  325.  
  326. return
  327.  
  328. /*:VRX         Menu_path_libpath_Click
  329. */
  330. Menu_path_libpath_Click:
  331.  
  332. search_method = "Libpath"
  333.  
  334. call do_search
  335.  
  336. return
  337.  
  338. /*:VRX         Menu_path_Path_Click
  339. */
  340. Menu_path_Path_Click:
  341.  
  342. search_method = "Path"
  343.  
  344. call do_search
  345.  
  346. return
  347.  
  348. /*:VRX         Menu_Report_Click
  349. */
  350. Menu_Report_Click:
  351.  
  352. if search_active = 1 then return
  353.  
  354. Call VRSet "Report","Set",0
  355.  
  356. Call VRSet VRWindow(),"StatusText","Reporting"
  357.  
  358. drop Data_list. 
  359.  
  360. Call VRMethod "Data_list","GetStringList","data_list."
  361.  
  362. if  data_list.0 = 0 then do
  363.     Call VRSet VRWindow(),"StatusText","Report Cancelled - ",
  364.     "you must do a search first."
  365.     return
  366.     end
  367.  
  368. buttons.0 = 2
  369. buttons.1 = "Ok"
  370. buttons.2 = "Cancel"
  371.  
  372. prompt = VRPrompt(VRWindow(),"Please enter an output file name for the report",,
  373.     "report","Report Prompt","buttons.")
  374.  
  375. if  prompt = 2 then do
  376.     Call VRSet VRWindow(),"StatusText","Report Cancelled"
  377.     return
  378.     end
  379.  
  380. x = VRCreateFile(report)
  381.  
  382. call lineout report,"Report for file:" search_for
  383. call lineout report,"Search Method is:" search_method "Using Sort Sequence:" sort_type
  384. call lineout report,"Generated on" date() time() "from current directory:",
  385.          current_dir
  386. call lineout report," "
  387.  
  388. if data_list.0 > 0 then do
  389.     call lineout report " "
  390.     do i = 1 to data_list.0
  391.        call lineout report,data_list.i
  392.        end
  393.     call lineout report," "
  394. end
  395.  
  396. Call lineout report
  397.  
  398. Call VRSet VRWindow(),"StatusText","Report Complete to" report
  399.  
  400. return
  401.  
  402. /*:VRX         Menu_Search_Click
  403. */
  404. Menu_Search_Click:
  405.  
  406. return
  407.  
  408. /*:VRX         Menu_Sort_Ascend_Click
  409. */
  410. Menu_Sort_Ascend_Click:
  411.  
  412. Sort_Type = "Ascend"
  413.  
  414. return
  415.  
  416. /*:VRX         Menu_Sort_Descend_Click
  417. */
  418. Menu_Sort_Descend_Click:
  419.  
  420. Sort_Type = "Descend"
  421.  
  422. return
  423.  
  424. /*:VRX         Menu_Sort_None_Click
  425. */
  426. Menu_Sort_None_Click:
  427.  
  428. Sort_Type = "None"
  429.  
  430. return
  431.  
  432. /*:VRX         Quit
  433. */
  434. Quit:
  435.     window = VRWindow()
  436.     call VRSet window, "Shutdown", 1
  437.     drop window
  438. return
  439.  
  440. /*:VRX         Window1_Close
  441. */
  442. Window1_Close:
  443.     call Quit
  444. return
  445.  
  446.