home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 14 / AACD14.ISO / SearchCDs < prev    next >
Text File  |  2000-03-31  |  23KB  |  658 lines

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