SearchCDs - Searches index files of Amiga Active CDs,
Aminet CDs and Aminet Online files
$VER: SearchCDs 1.6 (12.2.2001) (c) Neil Bothwick, Wirenet
*/
/* ;;; Initialise */
options results
signal on error
/* Make sure we have enough stack */
CurrStack = pragma('S',16384)
if CurrStack > 16384 then call pragma('S',CurrStack)
/* Set some variables */
VerStr = sourceline(4)
VerStr = subword(VerStr,2,words(VerStr) - 4)
Title = 'SearchCDs'
GuiPort = upper(Title)
PrgPort = GuiPort'-PRG'
WinTitle = 'Amiga Active CD Search'
WinTitle = 'Amiga Active CD preferences'
qt = '22'x
lf = '0a'x
GF = '<font color="green"><b>GF</b></font>'
GF = '<font color="red"><b>Q</b></font>'
/* Are we running from CD or HD? */
CurrentDir = pragma('D')
parse var CurrentDir CDname ':' .
if left(CDName,4) ~= 'AACD' then CDname = 'AACD'
signal off error
address command 'Assign >NIL: 'CDName': EXISTS'
CDMounted = ~(RC % 5)
/* Is registered AWeb available? */
address command 'Assign >NIL: AWeb3: EXISTS'
Browser = ''
if RC = 0 then do
address command 'Version >NIL: AWeb3:AWeb-II 3 3'
if RC = 0 then Browser = 'AWeb3:AWeb-II'
end
else if CDMounted = 1 then Browser = CDName':AACD/Information/Browsers/AWeb3/AWebDemo'
signal on error
AminetServer = 'de.aminet.net'
select
when right(CurrentDir,6) = 'Aminet' then DefSearch = 'Aminet Online'
when right(CurrentDir,3) = 'CDs' then DefSearch = 'Aminet CDs'
when right(CurrentDir,4) = 'Sets' then DefSearch = 'Aminet Sets'
otherwise DefSearch = 'Amiga Active CDs'
end
/* Load libraries */
call LoadLib('rexxsupport.library')
call LoadLib('rexxdossupport.library')
call LoadLib('rexxreqtools.library')
;;;
/* ;;; Check for MUI */
address command 'Assign >NIL: MUI: EXISTS'
if RC > 0 then do
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"'
exit
end
;;;
/* ;;; Set index variables and ensure all necessary files are available */
address command
signal off error
'which >NIL: FlashFind'
signal on error
if RC = 5 then 'copy 'CDname':System/C/FlashFind C: clone quiet'
if exists('ENV:AACDIndex') then AACDPath = AddPart(GetVar('AACDIndex'),'')
else AACDPath = CDname':CDTools/indices/'
if exists('ENV:AminetCDIndex') then AminetCDPath = AddPart(GetVar('AminetCDIndex'),'')
window id MAIN port PrgPort command 'QUIT' title '"'WinTitle'"'
group id ALL
group horiz attrs MUIA_Group_Columns 2
group horiz attrs MUIA_Group_Columns 2
label double 'Search string'
string id SCSTR help '"Enter a string to search for"' /*content 'test'*/
label double 'CDs to search'
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'
label double 'Output format'
if Browser > '' then cycle id OPFMT help '"Choose the output format"' labels 'HTML,Text,Amigaguide'
else cycle id OPFMT help '"Choose the output format"' labels 'Text,Amigaguide'
endgroup
if exists('AALogo.ilbm') then image id LOGO pict AALogo.ilbm
call writeln(out,'<h3 align=center>Result of searching 'Source' for "<font color=red>'SearchStr'</font>"</h3>')
call writeln(out,'<table width="100%">')
/* Process output into HTML */
'gauge id PROGR attrs' MUIA_Gauge_Max word(statef(OutFile),2) MUIA_Gauge_InfoText '"Processing search results"'
BytesDone = 0
select
when Source = 'Amiga Active CDs' then do
/* Format output */
do until eof(res)
line = readln(res)
BytesDone = BytesDone + length(line) + 1
if line = '' then iterate
parse var line name =34 path
name = strip(name)
line = '<tr><td>'name'<td><a href="x-aweb:rexx/REXX:AAShowDir 'PathPart(path)'">'path'</a>'
call writeln(out,line)
'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
end
end
when Source = 'Aminet CDs' then do
/* Format output */
call readln(res)
do until eof(res)
CDTitle = readln(res)
call SetCDTitle()
line = readln(res)
do while ~eof(res) & line ~= ''
BytesDone = BytesDone + length(line) + 1
if left(line,1) ~= '|' then do
/*parse var line name =19 path =30 size +5 age +5 desc*/
interpret parsecmd
name = strip(name)
path = CDTitle'Aminet/'strip(path)'/'name
readme = left(path,lastpos('.',path))'readme'
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>'
call writeln(out,line)
'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
end
line = readln(res)
end
end
end
when Source = 'Aminet Sets' then do
/* Format output */
call readln(res)
do until eof(res)
line = readln(res)
BytesDone = BytesDone + length(line) + 1
if left(line,1) = '|' then iterate
parse var line name =20 path +11 size +5 age +4 CD +2 x +1 desc
name = strip(name)
path = 'AminetSet'CD':Aminet/'strip(path)'/'name
readme = left(path,lastpos('.',path))'readme'
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>'
call writeln(out,line)
'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
end
end
when Source = 'Aminet Online' then do
/* Format output */
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>')
call writeln(out,'Alternatively, click on 'GF' to add the file or readme to the GoFetch! download queue.')
call writeln(out,'This requires that you have GoFetch! installed, you can install it from ')
'gauge id PROGR attrs' MUIA_Gauge_Current BytesDone
end
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>')
end
otherwise call ShowMsg('Not done this bit yet')
end
call writeln(out,'</table></body></html>')
call close(res)
call close(out)
/* Load HTML */
signal off error
address command 'waitforport' AWebPort
signal on error
if RC > 0 then call ExitMsg('Unable to start AWeb')
if ~open(dirs,AddPart(IndexPath,'dirlist'),'R') then 'echo >'OutFile'1 "Unable to open index list"'
else do until eof(dirs)
'echo >>'OutFile'1 "'readln(dirs)'"'
end
end
otherwise nop
end
if exists(OutFile) then do
if word(statef(OutFile),3) > 0 then 'sort' OutFile OutFile'1'
else 'echo >'OutFile'1 "No index files available in configured directory"'
end
/* Display list */
address(GuiPort)
if ~open(listfile,OutFile'1','R') then call ExitMsg('Error reading file')
do while ~eof(listfile)
line = readln(listfile)
if line > '' then 'list id CDLST insert string' line
end
call close(listfile)
'application' MUIA_Application_Sleep FALSE
'list id CDLST attrs' MUIA_List_Quiet FALSE
return
;;;
/* ;;; Translate Index file name into CD title */
SetCDTitle:
select
when CDTitle = 'AMINET01:' then do
CDTitle = 'AMINET_0693:'
parsecmd = "name='';size=line;desc='';path=''"
end
when CDTitle = 'AMINET02:' then do
CDTitle = 'AMINET_0294:'
parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
end
when CDTitle = 'AMINET03:' then do
CDTitle = 'AMINET_0794:'
parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
end
when CDTitle = 'AMINET04:' then do
CDTitle = 'AMINET4:'
parsecmd = 'parse var line name =22 path =33 size =37 age =38 desc'
end
when substr(CDTitle,7,1) = '0' then do
parsecmd = 'parse var line name =20 path =31 size =37 age =40 desc'
CDTitle = compress(CDTitle,'0')
end
otherwise parsecmd = 'parse var line name =20 path =31 size =37 age =40 desc'
end
return
;;;
/* ;;; Error handler */
Error:
oldaddress = address()
address(GuiPort)
call ShowMsg('Error' RC 'in line' sigl)
address(oldaddress)
if RC = 5 then return
call Cleanup()
return
;;;
/* ;;; Install index files for older CDs */
InstallOld:
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')
if res = 0 then return
if AACDPath = CDname':CDTools/indices/' then do
call ShowMsg('You must set the path for your copies\nof the index files in AACDPrefs')
return
end
LastCD = GetVar('AACDlast')
LastCD = substr(LastCD, 5, 2)
CmdStr = 'LhA -q x 'CDName':CDTools/indices/OldIndices.lha'
do i = 1 to LastCD - 10
ThisCD = 'AACD'right(i, 2, '00')
if ~exists(IndexPath||ThisCD) then CmdStr = CmdStr ThisCD
end
CmdStr = CmdStr IndexPath
address command CmdStr
call ShowMsg('Index files have been copied to\n'IndexPath)