home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / SearchCDs < prev    next >
Text File  |  2000-10-08  |  23KB  |  663 lines

  1. /*
  2. SearchCDs - Searches index files of Amiga Active CDs,
  3.             Aminet CDs and Aminet Online files
  4. $VER: SearchCDs 1.5 (6.10.00) (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. /* ;;; Subroutines */
  220. ;;;
  221. /* ;;; Load a library */
  222. LoadLib:
  223.     parse arg library
  224.     if show('L',library) then return
  225.     if ~exists('LIBS:'library) then address command 'copy 'CDname':libs/'library 'LIBS: clone quiet'
  226.     if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
  227.     return
  228. ;;;
  229. /* ;;; Show a message in a requester */
  230. ShowMsg:
  231.     parse arg msg
  232.     oldaddr = address()
  233.     address(GuiPort)
  234.     'request id MAIN title "'WinTitle'" gadgets "OK" string' msg
  235.     choice = result
  236.     address(oldaddr)
  237.     return choice
  238. ;;;
  239. /* ;;; Exit with a requester */
  240. ExitMsg:
  241.     parse arg msg
  242.     call ShowMsg(msg)
  243.     call Cleanup()
  244.     return
  245. ;;;
  246. /* ;;; Cleanup and exit */
  247. CleanUp:
  248.     if getclip('GFStarted') = 1 then do
  249.         if show('P','GOFETCH') then address 'GOFETCH' 'quit'
  250.         call setclip('GFStarted')
  251.         end
  252.     call delete(OutFile'#?')
  253.     address(GuiPort)
  254.     'cycle id OPFMT'
  255.     address command 'setenv AACDSearchFormat' result
  256.     address command 'copy ENV:AACDSearchFormat ENVARC:'
  257.     'QUIT'
  258.     exit
  259. ;;;
  260. /* ;;; Search CDs */
  261. Search:
  262. 'cycle id OPFMT'
  263. Format = result
  264.     call delete(OutFile)
  265.     'gauge id PROGR attrs' MUIA_Gauge_Max CDs.0 MUIA_Gauge_InfoText '%ld/'CDs.0
  266.     do i = 1 to CDs.0
  267.         'gauge id PROGR attrs' MUIA_Gauge_Current i
  268.         select
  269.             when Source = 'Aminet CDs' then address command 'echo "*NAMINET'right(CDs.i,2)':" >>'OutFile
  270.             /*when Source = 'Aminet Sets' then address command 'echo "*NAminetSet'right(CDs.i,1)':" >>'OutFile*/
  271.             when Format = 'Text' then NH = ''
  272.             otherwise NH = 'NH'
  273.             end
  274.         signal off error
  275.         address command 'FlashFind >>'OutFile AddPart(IndexPath,CDs.i) '"'SearchStr'" NOPREFS QUIET' NH
  276.         signal on error
  277.         end
  278. ;;;
  279. /* ;;; Show matches or warn if none */
  280. if word(statef(OutFile),2) = 0 then do
  281.     call ShowMsg('No matches found for "'SearchStr'"')
  282.     return
  283.     end
  284. if ~open(res,OutFile,'R') then do
  285.     call ShowMsg('File open failure')
  286.     return
  287.     end
  288. if ~open(out,OutFile'1','W') then do
  289.     call ShowMsg('File open failure')
  290.     return
  291.     end
  292.  
  293. select
  294. ;;;
  295.     /* ;;; Show Text */
  296.     when Format = 'Text' then do
  297.         if Source ='Aminet CDs' then do
  298.             /* Format output */
  299.             'gauge id PROGR attrs' MUIA_Gauge_Max word(statef(OutFile),2) MUIA_Gauge_InfoText '"Processing search results"'
  300.             BytesDone = 0
  301.             call readln(res)
  302.             do until eof(res)
  303.                 CDTitle = readln(res)
  304.                 call SetCDTitle()
  305.                 line = readln(res)
  306.                 do while ~eof(res) & line ~= ''
  307.                     BytesDone = BytesDone + length(line) + 1
  308.                     if left(line,1) ~= '|' then do
  309.                         parse var line name =19 path =30 .
  310.                         name = strip(name)
  311.                         path = CDTitle'Aminet/'strip(path)'/'name
  312.                         line = left(name'                                    ',33)||path
  313.                         call writeln(out,line)
  314.                         'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  315.                         end
  316.                     line = readln(res)
  317.                     end
  318.                 end
  319.             end
  320.         else do
  321.             call close(out)
  322.             call delete(OutFile'1')
  323.             call rename(OutFile,OutFile'1')
  324.             end
  325.  
  326.         call close(res)
  327.         call close(out)
  328.         address command 'Run >NIL: Multiview' OutFile'1'
  329.         call delete(OutFile'1')
  330.         end
  331.     ;;;
  332.     /* ;;; Show HTML */
  333.     when Format = 'HTML' then do
  334.         /* Find AWeb's arexx port or start it if not running */
  335.         ports = show('P')
  336.         portpos = pos('AWEB.',ports)
  337.         if portpos > 0 then AWebPort = word(substr(ports,portpos),1)
  338.         else do
  339.             address command 'Run >NIL:' Browser 'CONFIG Amigactive'
  340.             AWebPort = 'AWEB.1'
  341.             end
  342.  
  343.         /* Open output file and write headers */
  344.         call writeln(out,'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">')
  345.         call writeln(out,'<html><head><title>Search results</title></head><body bgcolor=white>')
  346.         call writeln(out,'<h3 align=center>Result of searching 'Source' for "<font color=red>'SearchStr'</font>"</h3>')
  347.         call writeln(out,'<table width="100%">')
  348.  
  349.         /* Process output into HTML */
  350.         'gauge id PROGR attrs' MUIA_Gauge_Max word(statef(OutFile),2) MUIA_Gauge_InfoText '"Processing search results"'
  351.         BytesDone = 0
  352.         select
  353.             when Source = 'Amiga Active CDs' then do
  354.                 /* Format output */
  355.                 do until eof(res)
  356.                     line = readln(res)
  357.                     BytesDone = BytesDone + length(line) + 1
  358.                     if line = '' then iterate
  359.                     parse var line name =34 path
  360.                     name = strip(name)
  361.                     line = '<tr><td>'name'<td><a href="x-aweb:rexx/REXX:AAShowDir 'PathPart(path)'">'path'</a>'
  362.                     call writeln(out,line)
  363.                     'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  364.                     end
  365.                 end
  366.             when Source = 'Aminet CDs' then do
  367.                 /* Format output */
  368.                 call readln(res)
  369.                 do until eof(res)
  370.                     CDTitle = readln(res)
  371.                     call SetCDTitle()
  372.                     line = readln(res)
  373.  
  374.                     do while ~eof(res) & line ~= ''
  375.                         BytesDone = BytesDone + length(line) + 1
  376.                         if left(line,1) ~= '|' then do
  377.                             /*parse var line name =19 path =30 size +5 age +5 desc*/
  378.                             interpret parsecmd
  379.                             name = strip(name)
  380.                             path = CDTitle'Aminet/'strip(path)'/'name
  381.                             readme = left(path,lastpos('.',path))'readme'
  382.                             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>'
  383.                             call writeln(out,line)
  384.                             'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  385.                             end
  386.                         line = readln(res)
  387.                         end
  388.                     end
  389.                 end
  390.             when Source = 'Aminet Sets' then do
  391.                 /* Format output */
  392.                 call readln(res)
  393.                 do until eof(res)
  394.                     line = readln(res)
  395.                     BytesDone = BytesDone + length(line) + 1
  396.                     if left(line,1) = '|' then iterate
  397.                     parse var line name =20 path +11 size +5 age +4 CD +2 x +1 desc
  398.                     name = strip(name)
  399.                     path = 'AminetSet'CD':Aminet/'strip(path)'/'name
  400.                     readme = left(path,lastpos('.',path))'readme'
  401.                     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>'
  402.                     call writeln(out,line)
  403.                     'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  404.                     end
  405.                 end
  406.             when Source = 'Aminet Online' then do
  407.                 /* Format output */
  408.  
  409.                 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>')
  410.                 call writeln(out,'Alternatively, click on 'GF' to add the file or readme to the GoFetch! download queue.')
  411.                 call writeln(out,'This requires that you have GoFetch! installed, you can install it from ')
  412.                 call writeln(out,'<a href="x-aweb:rexx/REXX:AAShowDir AACD:Online/Resources/GoFetch!">AACD:Online/Resources/GoFetch!</a><p></td></tr>')
  413.                 call writeln(out,'<tr><td><p>  </p></td></tr>')
  414.  
  415.                 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>')
  416.                 do until eof(res)
  417.                     line = readln(res)
  418.                     BytesDone = BytesDone + length(line) + 1
  419.                     if line = '' | left(line,1) = '|' then iterate
  420.                     parse var line name =20 path +11 size +5 age +3 x +1 desc
  421.                     name = strip(name)
  422.                     path = 'ftp://'AminetServer'/pub/aminet/'strip(path)'/'name
  423.                     readme = left(path,lastpos('.',path))'readme'
  424.                     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>'
  425.                     call writeln(out,line)
  426.                     'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  427.                     end
  428.                 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>')
  429.                 end
  430.             
  431.             otherwise call ShowMsg('Not done this bit yet')
  432.             end
  433.         call writeln(out,'</table></body></html>')
  434.         call close(res)
  435.         call close(out)
  436.  
  437.         /* Load HTML */
  438.         signal off error
  439.         address command 'waitforport' AWebPort
  440.         signal on error
  441.         if RC > 0 then call ExitMsg('Unable to start AWeb')
  442.         /*call delete(OutFile)*/
  443.         call delete(OutFile'.html')
  444.         call rename(OutFile'1',OutFile'.html')
  445.         address(AWebPort)
  446.         'open file://localhost/'OutFile'.html reload'
  447.         'screentofront'
  448.         'window tofront'
  449.  
  450.         end
  451.     ;;;
  452.     /* ;;; Show Amigaguide */
  453.     when Format = 'Amigaguide' then do
  454.  
  455.         /* Open output file and write headers */
  456.         call writeln(out,'@database "AACD Search Results"')
  457.         call writeln(out,'@master 'OutFile'1')
  458.         call writeln(out,'@author "SearchCDs"')
  459.         call writeln(out,'@remark "Created by Amiga Active CD SearchCDs"')
  460.         call writeln(out,'')
  461.         call writeln(out,'@node "Main" "Result of searching 'Source' for 'SearchStr'"')
  462.         call writeln(out,'@{jcenter}')
  463.         call writeln(out,'@{b}@{u}Result of searching 'Source' for 'SearchStr'@{ub}@{uu}')
  464.         call writeln(out,'@{jleft}')
  465.  
  466.         /* Process output into Amigaguide */
  467.         'gauge id PROGR attrs' MUIA_Gauge_Max word(statef(OutFile),2) MUIA_Gauge_InfoText '"Processing search results"'
  468.         BytesDone = 0
  469.         select
  470.             when Source = 'Amiga Active CDs' then do
  471.                 /* Format output */
  472.                 do until eof(res)
  473.                     line = readln(res)
  474.                     BytesDone = BytesDone + length(line) + 1
  475.                     if line = '' then iterate
  476.                     parse var line name =34 path
  477.                     name = strip(name)
  478.                     line = '@{" 'name' " system "rx REXX:AAShowDir 'PathPart(path)'" }'left('',32 - length(name)) path
  479.                     call writeln(out,line)
  480.                     'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  481.                     end
  482.                 end
  483.             when Source = 'Aminet CDs' then do
  484.                 /* Format output */
  485.                 call readln(res)
  486.                 do until eof(res)
  487.                     CDTitle = readln(res)
  488.                     call SetCDTitle
  489.                     line = readln(res)
  490.  
  491.                     do while ~eof(res) & line ~= ''
  492.                         BytesDone = BytesDone + length(line) + 1
  493.                         if left(line,1) ~= '|' then do
  494.                             interpret parsecmd
  495.                             name = strip(name)
  496.                             path = CDTitle'Aminet/'strip(path)'/'name
  497.                             readme = left(path,lastpos('.',path))'readme'
  498.                             desc = compress(desc,'"')
  499.                             line = '@{" 'name' " system "rx REXX:AAExtract 'path'" }'left('',32 - length(name))||right('      'strip(size),5) '@{" 'desc' " system "Run >NIL: AACDfile 'readme'"}'
  500.                             call writeln(out,line)
  501.                             'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  502.                             end
  503.                         line = readln(res)
  504.                         end
  505.                     end
  506.                 end
  507.  
  508.             when Source = 'Aminet Sets' then do
  509.                 /* Format output */
  510.                 call readln(res)
  511.                 do until eof(res)
  512.                     line = readln(res)
  513.                     BytesDone = BytesDone + length(line) + 1
  514.                     if left(line,1) = '|' then iterate
  515.                     parse var line name =20 path +11 size +5 age +4 CD +2 x +1 desc
  516.                     name = strip(name)
  517.                     path = 'AminetSet'CD':Aminet/'strip(path)'/'name
  518.                     readme = left(path,lastpos('.',path))'readme'
  519.                     desc = compress(desc,'"')
  520.                     line = '@{" 'name' " system "rx REXX:AAExtract 'path'" }'left('',32 - length(name))||right('      'strip(size),5) '@{" 'desc' " system "Run >NIL: AACDfile 'readme'"}'
  521.                     call writeln(out,line)
  522.                     'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  523.                     end
  524.                 end
  525.             when Source = 'Aminet Online' then do
  526.                 /* Format output */
  527.                 call writeln(out,'Click on the file name to add it to the GoFetch! download queue.')
  528.                 call writeln(out,'Click on the short description to download the readme.'lf)
  529.                 call writeln(out,'@{b}Name                              Size  Age Description@{ub}')
  530.                 
  531.                 do until eof(res)
  532.                     line = readln(res)
  533.                     BytesDone = BytesDone + length(line) + 1
  534.                     if line = '' | left(line,1) = '|' then iterate
  535.                     parse var line name =20 path +11 size +5 age +3 x +1 desc
  536.                     name = strip(name)
  537.                     path = 'ftp://'AminetServer'/pub/aminet/'strip(path)'/'name
  538.                     readme = left(path,lastpos('.',path))'readme'
  539.                     desc = compress(desc,'"')
  540.                     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'"}'
  541.                     call writeln(out,line)
  542.                     'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
  543.                     end
  544.                 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')')')
  545.                 end
  546.             otherwise call ShowMsg('Not done this bit yet')
  547.             end
  548.         
  549.         call writeln(out,'@endnode')
  550.         call close(res)
  551.         call close(out)
  552.  
  553.         /* Load Amigaguide */
  554.         address command 'Run >NIL: Multiview' OutFile'1'
  555.         call delete(OutFile'1')
  556.         end
  557.  
  558.     otherwise do
  559.         call ShowMsg('Not done this bit yet')
  560.         call close(res)
  561.         call close(out)
  562.         return
  563.         end
  564.     end
  565. call close(res)
  566. call close(out)
  567.  
  568. address(GuiPort)
  569. 'gauge id PROGR attrs' MUIA_Gauge_Current 0 MUIA_Gauge_InfoText '""'
  570. return
  571. ;;;
  572. /* ;;; List CDs for searching */
  573. LoadList:
  574.     address(GuiPort)
  575.     'list id CDLST attrs' MUIA_List_Quiet TRUE
  576.     'application' MUIA_Application_Sleep TRUE
  577.     /* Clear list */
  578.     'method id CDLST' MUIM_List_Select MUIV_List_Select_All MUIV_List_Select_On
  579.     'method id CDLST' MUIM_List_Remove MUIV_List_Remove_Selected
  580.     /* Create index list */
  581.     'cycle id CDTYP'
  582.     Source = result
  583.     address command
  584.     call delete(OutFile)
  585.     call delete(OutFile'1')
  586.     select
  587.         when Source = 'Amiga Active CDs' then do
  588.             IndexPath = AACDPath
  589.             'list' IndexPath 'pat AACD?? lformat "%N" to' OutFile
  590.             end
  591.         when Source = 'Aminet CDs' then do
  592.             IndexPath = AminetCDPath
  593.             'list' IndexPath 'pat Index?? lformat "%N" to' OutFile
  594.             end
  595.         when Source = 'Aminet Sets' then do
  596.             IndexPath = AminetSetPath
  597.             'list' IndexPath 'pat Set? lformat "%N" to' OutFile
  598.             end
  599.         when Source = 'Aminet Online' then do
  600.             IndexPath = AminetPath
  601.             if ~open(dirs,AddPart(IndexPath,'dirlist'),'R') then 'echo >'OutFile'1 "Unable to open index list"'
  602.             else do until eof(dirs)
  603.                 'echo >>'OutFile'1 "'readln(dirs)'"'
  604.                 end
  605.             end
  606.         otherwise nop
  607.         end
  608.     if exists(OutFile) then do
  609.         if word(statef(OutFile),3) > 0 then    'sort' OutFile OutFile'1'
  610.         else 'echo >'OutFile'1 "No index files available in configured directory"'
  611.         end
  612.  
  613.     /* Display list */
  614.     address(GuiPort)
  615.     if ~open(listfile,OutFile'1','R') then call ExitMsg('Error reading file')
  616.     do while ~eof(listfile)
  617.         line = readln(listfile)
  618.         if line > '' then 'list id CDLST insert string' line
  619.         end
  620.     call close(listfile)
  621.     'application' MUIA_Application_Sleep FALSE
  622.     'list id CDLST attrs' MUIA_List_Quiet FALSE
  623.     return
  624. ;;;
  625. /* ;;; Translate Index file name into CD title */
  626. SetCDTitle:
  627.     select
  628.         when CDTitle = 'AMINET01:' then do
  629.             CDTitle = 'AMINET_0693:'
  630.             parsecmd = "name='';size=line;desc='';path=''"
  631.             end
  632.         when CDTitle = 'AMINET02:' then do
  633.             CDTitle = 'AMINET_0294:'
  634.             parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
  635.             end
  636.         when CDTitle = 'AMINET03:' then do
  637.             CDTitle = 'AMINET_0794:'
  638.             parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
  639.             end
  640.         when CDTitle = 'AMINET04:' then do
  641.             CDTitle = 'AMINET4:'
  642.             parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
  643.             end
  644.         when substr(CDTitle,7,1) = '0' then do
  645.             parsecmd = 'parse var line name =20 path =31 size =37 age =40 desc'
  646.             CDTitle = compress(CDTitle,'0')
  647.             end
  648.         otherwise parsecmd = 'parse var line name =20 path =31 size =37 age =40 desc'
  649.         end
  650.     return
  651. ;;;
  652. /* ;;; Error handler */
  653. Error:
  654.     oldaddress = address()
  655.     address(GuiPort)
  656.     call ShowMsg('Error' RC 'in line' sigl)
  657.     address(oldaddress)
  658.     if RC = 5 then return
  659.     call Cleanup()
  660.     return
  661. ;;;
  662.  
  663.