home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / SearchCDs < prev    next >
Text File  |  2001-03-13  |  24KB  |  692 lines

  1. /*
  2. SearchCDs - Searches index files of Amiga Active CDs,
  3.             Aminet CDs and Aminet Online files
  4. $VER: SearchCDs 1.6 (12.2.2001) (c) Neil Bothwick, Wirenet
  5. */
  6.  
  7. /* ;;; Initialise */
  8. options results
  9. signal on error
  10. /* Make sure we have enough stack */
  11. CurrStack = pragma('S',16384)
  12. if CurrStack > 16384 then call pragma('S',CurrStack)
  13.  
  14. /* Set some variables */
  15. VerStr    = sourceline(4)
  16. VerStr    = subword(VerStr,2,words(VerStr) - 4)
  17. Title     = 'SearchCDs'
  18. GuiPort   = upper(Title)
  19. PrgPort   = GuiPort'-PRG'
  20. WinTitle  = 'Amiga Active CD Search'
  21. WinTitle  = 'Amiga Active CD preferences'
  22. qt        = '22'x
  23. lf        = '0a'x
  24. GF        = '<font color="green"><b>GF</b></font>'
  25. GF        = '<font color="red"><b>Q</b></font>'
  26.  
  27. /* Are we running from CD or HD? */
  28. CurrentDir = pragma('D')
  29. parse var CurrentDir CDname ':' .
  30. if left(CDName,4) ~= 'AACD' then CDname = 'AACD'
  31. signal off error
  32. address command 'Assign >NIL: 'CDName': EXISTS'
  33. CDMounted = ~(RC % 5)
  34.  
  35. /* Is registered AWeb available? */
  36. address command 'Assign >NIL: AWeb3: EXISTS'
  37. Browser = ''
  38. if RC = 0 then do
  39.     address command 'Version >NIL: AWeb3:AWeb-II 3 3'
  40.     if RC = 0 then Browser = 'AWeb3:AWeb-II'
  41.     end
  42. else if CDMounted = 1 then Browser = CDName':AACD/Information/Browsers/AWeb3/AWebDemo'
  43. signal on error
  44.  
  45. AminetServer = 'de.aminet.net'
  46. select
  47.     when right(CurrentDir,6) = 'Aminet' then DefSearch = 'Aminet Online'
  48.     when right(CurrentDir,3) = 'CDs' then DefSearch = 'Aminet CDs'
  49.     when right(CurrentDir,4) = 'Sets' then DefSearch = 'Aminet Sets'
  50.     otherwise DefSearch = 'Amiga Active CDs'
  51.     end
  52.  
  53. /* Load libraries */
  54. call LoadLib('rexxsupport.library')
  55. call LoadLib('rexxdossupport.library')
  56. call LoadLib('rexxreqtools.library')
  57. ;;;
  58. /* ;;; Check for MUI */
  59. address command 'Assign >NIL: MUI: EXISTS'
  60. if RC > 0 then do
  61.     address command 'RequestChoice >NIL: "Amiga Active CD" "This program require Magic User Interface*NRun the Welcome script for a temporary MUI setup,*Nor install it from the CDTools drawer of the CD" "OK"'
  62.     exit
  63.     end
  64. ;;;
  65. /* ;;; Set index variables and ensure all necessary files are available */
  66. address command
  67. signal off error
  68. 'which >NIL: FlashFind'
  69. signal on error
  70. if RC = 5 then 'copy 'CDname':System/C/FlashFind C: clone quiet'
  71. if exists('ENV:AACDIndex') then AACDPath = AddPart(GetVar('AACDIndex'),'')
  72. else AACDPath = CDname':CDTools/indices/'
  73. if exists('ENV:AminetCDIndex') then AminetCDPath = AddPart(GetVar('AminetCDIndex'),'')
  74. else AminetCDPath = CDname':AACD/Resources/CDROM/Aminet/CDs'
  75. if exists('ENV:AminetSetIndex') then AminetSetPath = AddPart(GetVar('AminetSetIndex'),'')
  76. else AminetSetPath = CDname':AACD/Resources/CDROM/Aminet/Sets'
  77. if exists('ENV:AminetIndex') then AminetPath = AddPart(GetVar('AminetIndex'),'')
  78. else AminetPath = CDname':AACD/Resources/Online/Aminet/'
  79. OutFile = 'T:SearchCDs.results'
  80. ;;;
  81. /* ;;; Define MUI variables */
  82. MUIA_List_Quiet                   = 0x8042d8c7
  83. MUIM_List_Select                  = 0x804252d8
  84. MUIV_List_Select_All              = -2
  85. MUIV_List_Select_On               = 1
  86. MUIV_List_Select_Ask              = 3
  87. MUIA_List_First                   = 0x804238d4
  88. MUIM_List_Remove                  = 0x8042647e
  89. MUIV_List_Remove_Selected         = -3
  90. MUIA_List_Entries                 = 0x80421654
  91. MUIA_List_Quiet                   = 0x8042d8c7
  92. MUIA_Listview_MultiSelect         = 0x80427e08
  93. MUIV_Listview_MultiSelect_Default = 1
  94. MUIA_Gauge_Current                = 0x8042f0dd
  95. MUIA_Gauge_Divide                 = 0x8042d8df
  96. MUIA_Gauge_Horiz                  = 0x804232dd
  97. MUIA_Gauge_InfoText               = 0x8042bf15
  98. MUIA_Gauge_Max                    = 0x8042bcdb
  99. MUIA_Group_Columns                = 0x8042f416
  100. MUIA_Menuitem_Shortcut            = 0x80422030
  101. MUIA_Application_Active           = 0x804260ab
  102. MUIA_Application_Author           = 0x80424842
  103. MUIA_Application_Copyright        = 0x8042ef4d
  104. MUIA_Application_Description      = 0x80421fc6
  105. MUIA_Application_HelpFile         = 0x804293f4
  106. MUIA_Application_Iconified        = 0x8042a07f
  107. MUIA_Application_Title            = 0x804281b8
  108. MUIA_Application_Version          = 0x8042b33f
  109. MUIA_Application_Sleep            = 0x80425711
  110. MUIM_Application_AboutMUI         = 0x8042d21d
  111. TRUE = 1
  112. FALSE = 0
  113. ;;;
  114. /* ;;; Open arexx port and GUI */
  115. thisport = openport(PrgPort)
  116. if thisport = 0 then exit
  117. address(GuiPort)
  118. window id MAIN port PrgPort command 'QUIT' title '"'WinTitle'"'
  119.     group id ALL
  120.         group horiz attrs MUIA_Group_Columns 2
  121.             group horiz attrs MUIA_Group_Columns 2
  122.                 label double 'Search string'
  123.                 string id SCSTR help '"Enter a string to search for"' /*content 'test'*/
  124.                 label double 'CDs to search'
  125.                 cycle id CDTYP port PrgPort command 'RESCAN' help '"Which types of CD do\nyou wish to search?"' labels 'Amiga Active CDs,Aminet CDs,Aminet Sets,Aminet Online'
  126.                 label double 'Output format'
  127.                 if Browser > '' then cycle id OPFMT help '"Choose the output format"' labels 'HTML,Text,Amigaguide'
  128.                 else cycle id OPFMT help '"Choose the output format"' labels 'Text,Amigaguide'
  129.                 endgroup
  130.             if exists('AALogo.ilbm') then image id LOGO pict AALogo.ilbm
  131.             else do
  132.                 if CDMounted then do
  133.                     if exists(CDName':AALogo.ilbm') then do
  134.                         address command 'Copy 'CDName':AALogo.ilbm "" CLONE'
  135.                         image id LOGO pict AALogo.ilbm
  136.                         end
  137.                     end
  138.                 end
  139.             endgroup
  140.  
  141.         list id CDLST attrs MUIA_Listview_MultiSelect MUIV_Listview_MultiSelect_Default help '"Select the CDs to search"'
  142.         group id BTNS horiz
  143.             button id GO  port PrgPort command 'SEARCH' help '"Start the search"' label 'Search'
  144.             button id ALL port PrgPort command 'ALL' help '"Select all CDs in the list"' label 'Select All'
  145.             button id ESC port PrgPort command 'QUIT' '"Exit without searching"' label 'Cancel'
  146.             endgroup
  147.         gauge id PROGR attrs MUIA_Gauge_Horiz MUIA_Gauge_InfoText '' help '"Shows the progress of the search"' label ''
  148.         endgroup
  149.     menu id PROJM label 'Project'
  150.         item id ABOUT port PrgPort command 'ABOUT' MUIA_Menuitem_Shortcut '?' label 'About'
  151.         item id MUI   port PrgPort command 'ABOUTMUI' label 'About MUI...'
  152.         item id QUITM port PrgPort command 'QUIT'  MUIA_Menuitem_Shortcut 'Q' label 'Quit'
  153.         endmenu
  154.     endwindow
  155.  
  156. cycle id CDTYP label DefSearch
  157. if exists('ENV:AACDSearchFormat') then cycle id OPFMT label GetVar('AACDSearchFormat')
  158.  
  159. call LoadList()
  160. 'application' MUIA_Application_Version '$VER: SearchCD 1.2 (15.4.99)'
  161. 'application' MUIA_Application_Author 'Neil Bothwick'
  162. 'application' MUIA_Application_Copyright '© 1998 by Neil Bothwick, Wirenet'
  163. 'application' MUIA_Application_Title 'SearchCD'
  164. 'application' MUIA_Application_Description 'Search AACD, and Aminet index files'
  165. /*'application' MUIA_Application_Description 'Search AACD and Aminet index files'*/
  166. ;;;
  167. /* ;;; Main loop */
  168. do forever
  169.     call waitpkt(PrgPort)
  170.     packet = getpkt(PrgPort)
  171.     if packet = '0000 0000'x then iterate
  172.     cmd = getarg(packet)
  173.     call reply(packet,0)
  174.     select
  175.     ;;;
  176. ;;;     /* Search */
  177.         when cmd = 'SEARCH' then do
  178.             'list id CDLST attrs' MUIA_List_Quiet TRUE
  179.             'application' MUIA_Application_Sleep TRUE
  180.             /* Get search string */
  181.             'string id SCSTR'
  182.             SearchStr = result
  183.             /* Get list of CDs to search */
  184.             drop CDs.
  185.             i = 0
  186.             do forever
  187.                  list id CDLST
  188.                  if result = '' then break
  189.                  i = i + 1
  190.                  CDs.i = result
  191.                  end
  192.             CDs.0 = i
  193.             select
  194.                 when SearchStr = '' then call ShowMsg('You must specify a string to search for')
  195.                 when CDs.0 = 0 then call ShowMsg('You must select at least one index to search')
  196.                 otherwise call Search()
  197.                 end
  198.             'application' MUIA_Application_Sleep FALSE
  199.             'list id CDLST attrs' MUIA_List_Quiet FALSE
  200.             end
  201. ;;;
  202. ;;;     /* Select All */
  203.         when cmd = 'ALL' then do
  204.             'method id CDLST' MUIM_List_Select MUIV_List_Select_All MUIV_List_Select_On
  205.             end
  206. ;;;
  207. ;;;     /* Rescan */
  208.         when cmd = 'RESCAN' then call LoadList()
  209. ;;;
  210. ;;;     /* About */
  211.         when cmd = 'ABOUT' then call ShowMsg(VerStr||'0a'x||'Programmed using MUIrexx')
  212.         when cmd = 'ABOUTMUI' then 'method ' MUIM_Application_AboutMUI 0
  213. ;;;
  214. ;;;     /* Cancel */
  215.         otherwise call CleanUp()
  216.         end
  217.     end
  218. ;;;
  219.  
  220. /* ;;; Subroutines */
  221. ;;;
  222. /* ;;; Load a library */
  223. LoadLib:
  224.     parse arg library
  225.     if show('L',library) then return
  226.     if ~exists('LIBS:'library) then address command 'copy 'CDname':libs/'library 'LIBS: clone quiet'
  227.     if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
  228.     return
  229. ;;;
  230. /* ;;; Show a message in a requester */
  231. ShowMsg:
  232.     msg = arg(1)
  233.     if arg() = 2 then Buttons = arg(2)
  234.     else Buttons = "OK"
  235.     oldaddr = address()
  236.     address(GuiPort)
  237.     'request id MAIN title "'WinTitle'" gadgets "'Buttons'" string' msg
  238.     choice = result
  239.     address(oldaddr)
  240.     return choice
  241. ;;;
  242. /* ;;; Exit with a requester */
  243. ExitMsg:
  244.     parse arg msg
  245.     call ShowMsg(msg)
  246.     call Cleanup()
  247.     return
  248. ;;;
  249. /* ;;; Cleanup and exit */
  250. CleanUp:
  251.     if getclip('GFStarted') = 1 then do
  252.         if show('P','GOFETCH') then address 'GOFETCH' 'quit'
  253.         call setclip('GFStarted')
  254.         end
  255.     call delete(OutFile'#?')
  256.     address(GuiPort)
  257.     'cycle id OPFMT'
  258.     address command 'setenv AACDSearchFormat' result
  259.     address command 'copy ENV:AACDSearchFormat ENVARC:'
  260.     'QUIT'
  261.     exit
  262. ;;;
  263. /* ;;; Search CDs */
  264. Search:
  265.     'cycle id OPFMT'
  266.     Format = result
  267.     interpret 'if abbrev(CDs.'CDs.0', " ") then do; call InstallOld(); return; end'
  268.  
  269.     call delete(OutFile)
  270.     'gauge id PROGR attrs' MUIA_Gauge_Max CDs.0 MUIA_Gauge_InfoText '%ld/'CDs.0
  271.     do i = 1 to CDs.0
  272.         'gauge id PROGR attrs' MUIA_Gauge_Current i
  273.         select
  274.             when Source = 'Aminet CDs' then address command 'echo "*NAMINET'right(CDs.i,2)':" >>'OutFile
  275.             /*when Source = 'Aminet Sets' then address command 'echo "*NAminetSet'right(CDs.i,1)':" >>'OutFile*/
  276.             when Format = 'Text' then NH = ''
  277.             otherwise NH = 'NH'
  278.             end
  279.         signal off error
  280.         address command 'FlashFind >>'OutFile AddPart(IndexPath,CDs.i) '"'SearchStr'" NOPREFS QUIET' NH
  281.         signal on error
  282.         end
  283. ;;;
  284.     /* ;;; Show matches or warn if none */
  285.     if word(statef(OutFile),2) = 0 then do
  286.         call ShowMsg('No matches found for "'SearchStr'"')
  287.         return
  288.         end
  289.     if ~open(res,OutFile,'R') then do
  290.         call ShowMsg('File open failure')
  291.         return
  292.         end
  293.     if ~open(out,OutFile'1','W') then do
  294.         call ShowMsg('File open failure')
  295.         return
  296.         end
  297.  
  298.     select
  299. ;;;
  300. ;;;        /* Show Text */
  301.         when Format = 'Text' then do
  302.             if Source ='Aminet CDs' then do
  303.                 /* Format output */
  304.                 'gauge id PROGR attrs' MUIA_Gauge_Max word(statef(OutFile),2) MUIA_Gauge_InfoText '"Processing search results"'
  305.                 BytesDone = 0
  306.                 call readln(res)
  307.                 do until eof(res)
  308.                     CDTitle = readln(res)
  309.                     call SetCDTitle()
  310.                     line = readln(res)
  311.                     do while ~eof(res) & line ~= ''
  312.                         BytesDone = BytesDone + length(line) + 1
  313.                         if left(line,1) ~= '|' then do
  314.                             parse var line name =19 path =30 .
  315.                             name = strip(name)
  316.                             path = CDTitle'Aminet/'strip(path)'/'name
  317.                             line = left(name'                                    ',33)||path
  318.                             call writeln(out,line)
  319.                             'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  320.                             end
  321.                         line = readln(res)
  322.                         end
  323.                     end
  324.                 end
  325.             else do
  326.                 call close(out)
  327.                 call delete(OutFile'1')
  328.                 call rename(OutFile,OutFile'1')
  329.                 end
  330.  
  331.             call close(res)
  332.             call close(out)
  333.             address command 'Run >NIL: Multiview' OutFile'1'
  334.             call delete(OutFile'1')
  335.             end
  336. ;;;
  337. ;;;        /* Show HTML */
  338.         when Format = 'HTML' then do
  339.             /* Find AWeb's arexx port or start it if not running */
  340.             ports = show('P')
  341.             portpos = pos('AWEB.',ports)
  342.             if portpos > 0 then AWebPort = word(substr(ports,portpos),1)
  343.             else do
  344.                 address command 'Run >NIL:' Browser 'CONFIG Amigactive'
  345.                 AWebPort = 'AWEB.1'
  346.                 end
  347.  
  348.             /* Open output file and write headers */
  349.             call writeln(out,'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">')
  350.             call writeln(out,'<html><head><title>Search results</title></head><body bgcolor=white>')
  351.             call writeln(out,'<h3 align=center>Result of searching 'Source' for "<font color=red>'SearchStr'</font>"</h3>')
  352.             call writeln(out,'<table width="100%">')
  353.  
  354.             /* Process output into HTML */
  355.             'gauge id PROGR attrs' MUIA_Gauge_Max word(statef(OutFile),2) MUIA_Gauge_InfoText '"Processing search results"'
  356.             BytesDone = 0
  357.             select
  358.                 when Source = 'Amiga Active CDs' then do
  359.                     /* Format output */
  360.                     do until eof(res)
  361.                         line = readln(res)
  362.                         BytesDone = BytesDone + length(line) + 1
  363.                         if line = '' then iterate
  364.                         parse var line name =34 path
  365.                         name = strip(name)
  366.                         line = '<tr><td>'name'<td><a href="x-aweb:rexx/REXX:AAShowDir 'PathPart(path)'">'path'</a>'
  367.                         call writeln(out,line)
  368.                         'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  369.                         end
  370.                     end
  371.                 when Source = 'Aminet CDs' then do
  372.                     /* Format output */
  373.                     call readln(res)
  374.                     do until eof(res)
  375.                         CDTitle = readln(res)
  376.                         call SetCDTitle()
  377.                         line = readln(res)
  378.  
  379.                         do while ~eof(res) & line ~= ''
  380.                             BytesDone = BytesDone + length(line) + 1
  381.                             if left(line,1) ~= '|' then do
  382.                                 /*parse var line name =19 path =30 size +5 age +5 desc*/
  383.                                 interpret parsecmd
  384.                                 name = strip(name)
  385.                                 path = CDTitle'Aminet/'strip(path)'/'name
  386.                                 readme = left(path,lastpos('.',path))'readme'
  387.                                 line = '<tr valign=top><td><a href="x-aweb:rexx/REXX:AAExtract 'path'">'name'<td align=right>'strip(size)'<td><a href="file://localhost/'readme'">'desc'</a>'
  388.                                 call writeln(out,line)
  389.                                 'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  390.                                 end
  391.                             line = readln(res)
  392.                             end
  393.                         end
  394.                     end
  395.                 when Source = 'Aminet Sets' then do
  396.                     /* Format output */
  397.                     call readln(res)
  398.                     do until eof(res)
  399.                         line = readln(res)
  400.                         BytesDone = BytesDone + length(line) + 1
  401.                         if left(line,1) = '|' then iterate
  402.                         parse var line name =20 path +11 size +5 age +4 CD +2 x +1 desc
  403.                         name = strip(name)
  404.                         path = 'AminetSet'CD':Aminet/'strip(path)'/'name
  405.                         readme = left(path,lastpos('.',path))'readme'
  406.                         line = '<tr><td><a href="x-aweb:rexx/REXX:AAExtract 'path'">'name'<td align=right>'strip(size)'<td><a href="file://localhost/'readme'">'desc'</a>'
  407.                         call writeln(out,line)
  408.                         'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  409.                         end
  410.                     end
  411.                 when Source = 'Aminet Online' then do
  412.                     /* Format output */
  413.  
  414.                     call writeln(out,'<tr><td colspan="4">Click on the file name to download it or the description to download the readme. This requires that you are online and does not work with the AACD Special Edition browser.<p>')
  415.                     call writeln(out,'Alternatively, click on 'GF' to add the file or readme to the GoFetch! download queue.')
  416.                     call writeln(out,'This requires that you have GoFetch! installed, you can install it from ')
  417.                     call writeln(out,'<a href="x-aweb:rexx/REXX:AAShowDir AACD:Online/Resources/GoFetch!">AACD:Online/Resources/GoFetch!</a><p></td></tr>')
  418.                     call writeln(out,'<tr><td><p>  </p></td></tr>')
  419.  
  420.                     call writeln(out,'<tr align="left"><td><b>Name</b></td><td align="right"><b>Size</b></td><td align="right"><b>Age</b></td><td><b>Description</td></tr>')
  421.                     do until eof(res)
  422.                         line = readln(res)
  423.                         BytesDone = BytesDone + length(line) + 1
  424.                         if line = '' | left(line,1) = '|' then iterate
  425.                         parse var line name =20 path +11 size +5 age +3 x +1 desc
  426.                         name = strip(name)
  427.                         path = 'ftp://'AminetServer'/pub/aminet/'strip(path)'/'name
  428.                         readme = left(path,lastpos('.',path))'readme'
  429.                         line = '<tr><td><a href="x-aweb:rexx/REXX:AAGoFetch 'path'">'GF'</a> <a href="'path'">'name'</a><td align=right>'strip(size)'<td align=right>'strip(age)'<td><a href="x-aweb:rexx/REXX:AAGoFetch 'readme'">'GF'</a> <a href="'readme'">'desc'</a>'
  430.                         call writeln(out,line)
  431.                         'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  432.                         end
  433.                     call writeln(out,'<tr><td align=center colspan=4><p><hr><p><h5>The age is given in weeks since the date of this index ('date('N',word(statef(AddPart(IndexPath,'INDEX')),5),'I')')</h5>')
  434.                     end
  435.                 
  436.                 otherwise call ShowMsg('Not done this bit yet')
  437.                 end
  438.             call writeln(out,'</table></body></html>')
  439.             call close(res)
  440.             call close(out)
  441.  
  442.             /* Load HTML */
  443.             signal off error
  444.             address command 'waitforport' AWebPort
  445.             signal on error
  446.             if RC > 0 then call ExitMsg('Unable to start AWeb')
  447.             /*call delete(OutFile)*/
  448.             call delete(OutFile'.html')
  449.             call rename(OutFile'1',OutFile'.html')
  450.             address(AWebPort)
  451.             'open file://localhost/'OutFile'.html reload'
  452.             'screentofront'
  453.             'window tofront'
  454.  
  455.             end
  456. ;;;
  457. ;;;        /* Show Amigaguide */
  458.         when Format = 'Amigaguide' then do
  459.  
  460.             /* Open output file and write headers */
  461.             call writeln(out,'@database "AACD Search Results"')
  462.             call writeln(out,'@master 'OutFile'1')
  463.             call writeln(out,'@author "SearchCDs"')
  464.             call writeln(out,'@remark "Created by Amiga Active CD SearchCDs"')
  465.             call writeln(out,'')
  466.             call writeln(out,'@node "Main" "Result of searching 'Source' for 'SearchStr'"')
  467.             call writeln(out,'@{jcenter}')
  468.             call writeln(out,'@{b}@{u}Result of searching 'Source' for 'SearchStr'@{ub}@{uu}')
  469.             call writeln(out,'@{jleft}')
  470.  
  471.             /* Process output into Amigaguide */
  472.             'gauge id PROGR attrs' MUIA_Gauge_Max word(statef(OutFile),2) MUIA_Gauge_InfoText '"Processing search results"'
  473.             BytesDone = 0
  474.             select
  475.                 when Source = 'Amiga Active CDs' then do
  476.                     /* Format output */
  477.                     do until eof(res)
  478.                         line = readln(res)
  479.                         BytesDone = BytesDone + length(line) + 1
  480.                         if line = '' then iterate
  481.                         parse var line name =34 path
  482.                         name = strip(name)
  483.                         line = '@{" 'name' " system "rx REXX:AAShowDir 'PathPart(path)'" }'left('',32 - length(name)) path
  484.                         call writeln(out,line)
  485.                         'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  486.                         end
  487.                     end
  488.                 when Source = 'Aminet CDs' then do
  489.                     /* Format output */
  490.                     call readln(res)
  491.                     do until eof(res)
  492.                         CDTitle = readln(res)
  493.                         call SetCDTitle
  494.                         line = readln(res)
  495.  
  496.                         do while ~eof(res) & line ~= ''
  497.                             BytesDone = BytesDone + length(line) + 1
  498.                             if left(line,1) ~= '|' then do
  499.                                 interpret parsecmd
  500.                                 name = strip(name)
  501.                                 path = CDTitle'Aminet/'strip(path)'/'name
  502.                                 readme = left(path,lastpos('.',path))'readme'
  503.                                 desc = compress(desc,'"')
  504.                                 line = '@{" 'name' " system "rx REXX:AAExtract 'path'" }'left('',32 - length(name))||right('      'strip(size),5) '@{" 'desc' " system "Run >NIL: AACDfile 'readme'"}'
  505.                                 call writeln(out,line)
  506.                                 'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  507.                                 end
  508.                             line = readln(res)
  509.                             end
  510.                         end
  511.                     end
  512.  
  513.                 when Source = 'Aminet Sets' then do
  514.                     /* Format output */
  515.                     call readln(res)
  516.                     do until eof(res)
  517.                         line = readln(res)
  518.                         BytesDone = BytesDone + length(line) + 1
  519.                         if left(line,1) = '|' then iterate
  520.                         parse var line name =20 path +11 size +5 age +4 CD +2 x +1 desc
  521.                         name = strip(name)
  522.                         path = 'AminetSet'CD':Aminet/'strip(path)'/'name
  523.                         readme = left(path,lastpos('.',path))'readme'
  524.                         desc = compress(desc,'"')
  525.                         line = '@{" 'name' " system "rx REXX:AAExtract 'path'" }'left('',32 - length(name))||right('      'strip(size),5) '@{" 'desc' " system "Run >NIL: AACDfile 'readme'"}'
  526.                         call writeln(out,line)
  527.                         'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  528.                         end
  529.                     end
  530.                 when Source = 'Aminet Online' then do
  531.                     /* Format output */
  532.                     call writeln(out,'Click on the file name to add it to the GoFetch! download queue.')
  533.                     call writeln(out,'Click on the short description to download the readme.'lf)
  534.                     call writeln(out,'@{b}Name                              Size  Age Description@{ub}')
  535.                     
  536.                     do until eof(res)
  537.                         line = readln(res)
  538.                         BytesDone = BytesDone + length(line) + 1
  539.                         if line = '' | left(line,1) = '|' then iterate
  540.                         parse var line name =20 path +11 size +5 age +3 x +1 desc
  541.                         name = strip(name)
  542.                         path = 'ftp://'AminetServer'/pub/aminet/'strip(path)'/'name
  543.                         readme = left(path,lastpos('.',path))'readme'
  544.                         desc = compress(desc,'"')
  545.                         line = '@{" 'name' " system "rx REXX:AAGoFetch 'path'" }'left('',32 - length(name))||right('      'strip(size),5)||right('      'strip(age),4) '@{" 'desc' " system "rx REXX:AAGoFetch 'readme'"}'
  546.                         call writeln(out,line)
  547.                         'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  548.                         end
  549.                     call writeln(out,lf'The age is given in weeks since the date of this index ('date('N',word(statef(AddPart(IndexPath,'INDEX')),5),'I')')')
  550.                     end
  551.                 otherwise call ShowMsg('Not done this bit yet')
  552.                 end
  553.             
  554.             call writeln(out,'@endnode')
  555.             call close(res)
  556.             call close(out)
  557.  
  558.             /* Load Amigaguide */
  559.             address command 'Run >NIL: Multiview' OutFile'1'
  560.             call delete(OutFile'1')
  561.             end
  562.  
  563.         otherwise do
  564.             call ShowMsg('Not done this bit yet')
  565.             call close(res)
  566.             call close(out)
  567.             return
  568.             end
  569.         end
  570.     call close(res)
  571.     call close(out)
  572.  
  573.     address(GuiPort)
  574.     'gauge id PROGR attrs' MUIA_Gauge_Current 0 MUIA_Gauge_InfoText '""'
  575.     return
  576. ;;;
  577. /* ;;; List CDs for searching */
  578. LoadList:
  579.     address(GuiPort)
  580.     'list id CDLST attrs' MUIA_List_Quiet TRUE
  581.     'application' MUIA_Application_Sleep TRUE
  582.     /* Clear list */
  583.     'method id CDLST' MUIM_List_Select MUIV_List_Select_All MUIV_List_Select_On
  584.     'method id CDLST' MUIM_List_Remove MUIV_List_Remove_Selected
  585.     /* Create index list */
  586.     'cycle id CDTYP'
  587.     Source = result
  588.     address command
  589.     call delete(OutFile)
  590.     call delete(OutFile'1')
  591.     select
  592.         when Source = 'Amiga Active CDs' then do
  593.             IndexPath = AACDPath
  594.             'list' IndexPath 'pat AACD?? lformat "%N" to' OutFile
  595.             if ~exists(IndexPath'AACD01') then 'echo " Older CDs" >>'OutFile
  596.             end
  597.         when Source = 'Aminet CDs' then do
  598.             IndexPath = AminetCDPath
  599.             'list' IndexPath 'pat Index?? lformat "%N" to' OutFile
  600.             end
  601.         when Source = 'Aminet Sets' then do
  602.             IndexPath = AminetSetPath
  603.             'list' IndexPath 'pat Set? lformat "%N" to' OutFile
  604.             end
  605.         when Source = 'Aminet Online' then do
  606.             IndexPath = AminetPath
  607.             if ~open(dirs,AddPart(IndexPath,'dirlist'),'R') then 'echo >'OutFile'1 "Unable to open index list"'
  608.             else do until eof(dirs)
  609.                 'echo >>'OutFile'1 "'readln(dirs)'"'
  610.                 end
  611.             end
  612.         otherwise nop
  613.         end
  614.     if exists(OutFile) then do
  615.         if word(statef(OutFile),3) > 0 then    'sort' OutFile OutFile'1'
  616.         else 'echo >'OutFile'1 "No index files available in configured directory"'
  617.         end
  618.  
  619.     /* Display list */
  620.     address(GuiPort)
  621.     if ~open(listfile,OutFile'1','R') then call ExitMsg('Error reading file')
  622.     do while ~eof(listfile)
  623.         line = readln(listfile)
  624.         if line > '' then 'list id CDLST insert string' line
  625.         end
  626.     call close(listfile)
  627.     'application' MUIA_Application_Sleep FALSE
  628.     'list id CDLST attrs' MUIA_List_Quiet FALSE
  629.     return
  630. ;;;
  631. /* ;;; Translate Index file name into CD title */
  632. SetCDTitle:
  633.     select
  634.         when CDTitle = 'AMINET01:' then do
  635.             CDTitle = 'AMINET_0693:'
  636.             parsecmd = "name='';size=line;desc='';path=''"
  637.             end
  638.         when CDTitle = 'AMINET02:' then do
  639.             CDTitle = 'AMINET_0294:'
  640.             parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
  641.             end
  642.         when CDTitle = 'AMINET03:' then do
  643.             CDTitle = 'AMINET_0794:'
  644.             parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
  645.             end
  646.         when CDTitle = 'AMINET04:' then do
  647.             CDTitle = 'AMINET4:'
  648.             parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
  649.             end
  650.         when substr(CDTitle,7,1) = '0' then do
  651.             parsecmd = 'parse var line name =20 path =31 size =37 age =40 desc'
  652.             CDTitle = compress(CDTitle,'0')
  653.             end
  654.         otherwise parsecmd = 'parse var line name =20 path =31 size =37 age =40 desc'
  655.         end
  656.     return
  657. ;;;
  658. /* ;;; Error handler */
  659. Error:
  660.     oldaddress = address()
  661.     address(GuiPort)
  662.     call ShowMsg('Error' RC 'in line' sigl)
  663.     address(oldaddress)
  664.     if RC = 5 then return
  665.     call Cleanup()
  666.     return
  667. ;;;
  668. /* ;;; Install index files for older CDs */
  669. InstallOld:
  670.     res = ShowMsg('Index files for the older AACDs are compressed to save space on the CD.\nThey must be installed on your hard drive before you can search them\n\nWould you like to install them now?', 'Yes|No')
  671.     if res = 0 then return
  672.  
  673.     if AACDPath = CDname':CDTools/indices/' then do
  674.         call ShowMsg('You must set the path for your copies\nof the index files in AACDPrefs')
  675.         return
  676.         end
  677.  
  678.     LastCD = GetVar('AACDlast')
  679.     LastCD = substr(LastCD, 5, 2)
  680.     CmdStr = 'LhA -q x 'CDName':CDTools/indices/OldIndices.lha'
  681.     do i = 1 to LastCD - 10
  682.         ThisCD = 'AACD'right(i, 2, '00')
  683.         if ~exists(IndexPath||ThisCD) then CmdStr = CmdStr ThisCD
  684.         end
  685.     CmdStr = CmdStr IndexPath
  686.     address command CmdStr
  687.  
  688.     call ShowMsg('Index files have been copied to\n'IndexPath)
  689.     call LoadList()
  690.     return
  691. ;;;
  692.