home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 117 / af117a.adf / archives / af117a1.lzx / Fiasco_2.2 / Databases / PictureDatabase / ScanDir.frx < prev    next >
Text File  |  1998-09-22  |  3KB  |  160 lines

  1. /* Scandir.rexx
  2.  * Support script for pictures.fdb
  3.  * Copyright © 1995-1997 Nils Bandener
  4.  * $VER: scandir_frx 6.3 (6.10.97)
  5.  */
  6.  
  7. Options Results
  8.  
  9. scriptname = "ScanDir"
  10.  
  11. fiasco_port = address()
  12.  
  13. Signal on Syntax
  14. Signal on Halt
  15. Signal on Break_C
  16. Signal on Failure
  17.  
  18. LockGUI
  19.  
  20. /*
  21.  *  Get the directory to search in
  22.  */
  23.  
  24. RequestFile Drawersonly ProjectRelative
  25.  
  26. if rc = 0 then do
  27.  
  28.     /*
  29.      *  User did not cancel the requester
  30.      */
  31.  
  32.     directory = Result
  33.  
  34.     RequestChoice '"Please select directory scan mode:*n1 - Selected only*n2 - Scan subdirectories*n3 - Scan subdirectories and lha archives" "1|2|3"'
  35.     Mode = Result
  36.  
  37.     /*
  38.      *  Create a list
  39.      */
  40.  
  41.     say "Scanning directory..."
  42.  
  43.     if mode = 2 | mode = 3 then
  44.     do
  45.         moreargs = "all"
  46.     end
  47.     else
  48.     do
  49.         moreargs = ""
  50.     end
  51.  
  52.     Address Command 'list >t:fpdb_files "' || directory || '" lformat %s%s files pat ~(#?.info) ' || moreargs
  53.  
  54.     if rc = 0 then
  55.     do
  56.  
  57.         Address Command "sort t:fpdb_files t:fpdbs_files"
  58.  
  59.         /* Address FIASCO */
  60.  
  61.         say "Adding pictures... (Press Ctrl-C for break)"
  62.  
  63.         if Open("g", "t:fpdbs_files", "read") then do
  64.  
  65.             do while ~eof("g")
  66.                 file = ReadLn("g")
  67.  
  68.                 if file ~= "" then
  69.                 do
  70.                     if right(file, 4) = ".lha" then
  71.                     do
  72.                         Address Command 'lha >t:fpdb_lha_files vq "' || file || '"'
  73.  
  74.                         if rc == 0 then
  75.                         do
  76.                             if Open("arc", "t:fpdb_lha_files", "read") then
  77.                             do
  78.                                 dummy = readln("arc")
  79.                                 dummy = readln("arc")
  80.                                 dummy = readln("arc")
  81.  
  82.                                 do while ~eof("arc")
  83.  
  84.                                     arcfile = readln("arc")
  85.  
  86.                                     if arcfile ~= "" then
  87.                                     do
  88.                                         say "Adding picture " || arcfile || " in archive " || file || "..."
  89.  
  90.                                         call addpicture.frx(file || '/__in_archive__/' || arcfile)
  91.  
  92.                                     end
  93.                                 end
  94.  
  95.                                 call Close("arc")
  96.                             end
  97.                         end
  98.                     end
  99.                     else
  100.                     do
  101.                         say "Adding picture " || file || "..."
  102.  
  103.                         call addpicture.frx(file)
  104.                     end
  105.                 end
  106.             end
  107.  
  108.             call Close("g")
  109.         end
  110.     end
  111. end
  112.  
  113. bail_out:
  114.  
  115. Address Value fiasco_port
  116.  
  117. UnlockGUI
  118. ResetStatus
  119.  
  120. exit
  121.  
  122. syntax:
  123. failure:
  124.  
  125. if show("Ports", fiasco_port) then
  126. do
  127.     Address Value fiasco_port
  128.  
  129.     RequestChoice '"Error ' || rc || ' in line ' || sigl || ':*n' || errortext(rc) || '" "Cancel" Title "' || scriptname || '"'
  130. end
  131. else
  132. do
  133.     say "Error" rc "in line" sigl ":" errortext(rc)
  134.     say "Enter to continue"
  135.     pull dummy
  136. end
  137.  
  138. call bail_out
  139.  
  140. halt:
  141. break_c:
  142.  
  143. if show("Ports", fiasco_port) then
  144. do
  145.     Address Value fiasco_port
  146.  
  147.     RequestChoice '"Script Abort Requested" "Abort Script" Title "' || scriptname || '"'
  148.  
  149.     if result = 0 then return
  150. end
  151. else
  152. do
  153.     say "*** Break"
  154.     say "Enter to continue"
  155.     pull dummy
  156. end
  157.  
  158. call bail_out
  159.  
  160.