home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #3
/
amigamamagazinepolishissue1998.iso
/
bazy
/
fiasco_2.1
/
databases
/
pd-disks
/
readfish.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-06-29
|
9KB
|
425 lines
/* ReadFish.rexx
* Copyright © 1995-1996 Nils Bandener
* $VER: ReadFish_rexx 5.7 (29.6.96)
*/
/* This script is able to read the "Contents" files of PD disks and
* create an record for each program in the database in this
* directory. It is also able to read several files, which have been
* joined together. Currently these formats are supported:
* - Fred Fish (and compatible)
* - SaarAG
* - Amiga-Magazin PD
*/
Options Results
Address FIASCO
Signal on Syntax
Signal on Halt
Signal on Break_C
Signal on Failure
F_LockGUI
tab = X2C("09")
status = "None"
verstat = "None"
format = "None"
notabs = 1
desc = ""
prog = ""
vers = ""
auth = ""
disk = ""
series = ""
F_RequestFile '"Contents"' Title '"Select contents file"' NoIcons /* Have to use
* the single
* Quotes, because
* ARexx would
* swallow the
* double quotes
*/
if rc = 0 then do
fishfile = result
if Open("cont", fishfile, "read") then do
do while ~eof("cont") & status ~= "End"
line = ReadLn("cont")
if Length(Compress(line,"~-=*")) < 5 then line = Compress(line,"~-=*")
if Abbrev(line,"This is disk") then do
/*
* Start of Fish contents file
*/
head = line
disk = Word(head,Find(Upper(head),"DISK")+1)
format = "Fish"
status = "Disk"
if subword(line, 5, 6) = "of the freely distributable AMIGA software" then do
series = "Fish Disk"
end
else do
series = ""
end
end
else if Abbrev(line,"CONTENTS") then do
head = line
disk = Word(head,Find(Upper(head),"DISK")+1)
status = "Disk"
series = ""
end
else if Abbrev(line,"Below is a listing") then do
/*
* Ignore this line
*/
nop
end
else if Abbrev(line,"Ausgabe:") then do
issue = Word(line,2)
line = ReadLn("cont")
format = "AmigaMag"
disk = issue || "," || Word(line,2)
status = "Disk"
end
else if Abbrev(line,"Programm:") & format = "AmigaMag" then do
/*
* if there is already a description,
* send it to Fiasco
*/
if status = "Program" then call DumpRecord
prog = Word(line,2)
status = "Program"
verstat = "Done"
/*
* read additional information
*/
/* Rubrik */
line = ReadLn("cont")
/* Version */
line = ReadLn("cont")
vers = SubWord(line,2)
/* Update */
line = ReadLn("cont")
line = ReadLn("cont")
end
else if Length(line) <= 1 then do
/*
* An empty line is interpreted as the end
* of a program description
*/
if status = "Program" then do
call DumpRecord
status = "Disk"
end
end
else if Pos(tab,line) ~= 0 then do
/*
* The file contains tabs
*/
notabs = 0
if status = "Disk" & format = "Fish" then do
/* Read first line */
status = "Program"
verstat = "None"
prog = Left(line,Pos(tab,line)-1)
if length(prog) <= 1 then do
status = "End"
end
end
if status = "Program" then do
/*
* Filter tabs
*/
txt = SubStr(line,Lastpos(tab,line)+1)
/*
* Parse the line
*/
call ParseDesc
end
end
else if notabs = 1 then do
/*
* The file does not contain tabs
*/
if status = "Disk" & Left(line,3) ~= " " then do
/*
* Read first line
*/
status = "Program"
verstat = "None"
prog = Word(line,1)
line = DelWord(line,1,1)
/*
* If program string is empty, stop processing
*/
if length(prog) <= 1 then do
status = "End"
end
/*
* Fall through the next if, if status = "program"
*/
end
if status = "Program" then do
txt = Strip(line)
/*
* Parse the line
*/
call ParseDesc
end
end
else do
if status = "Program" then do
call DumpRecord
status = "Disk"
end
end
end
if status = "Program" then do
call DumpRecord
end
call Close("cont")
end
else F_RequestChoice '"Could not open ' || fishfile || '"' '"Ok"'
end
F_UnlockGUI
exit
/*
* ParseDesc takes an already pre-processed line and reads
* information such as version and author from it.
*/
ParseDesc:
if Abbrev(txt,"Author") | Abbrev(txt,"Autor") then do
/*
* Remember author of program
*/
auth = SubWord(txt,2)
end
else do
if verstat = "NextLine" then do
/*
* Read version string.
* Version keyword was the last word in the
* previous line. Thus, the first word in this
* line must be the version.
*/
vers = Word(txt,1)
vers = Strip(vers,"T",D2C(44))
vers = Strip(vers,"T",".")
vers = Strip(vers,"T",",")
txt = DelWord(txt,1,1)
verstat = "Done"
end
else if verstat = "None" then do
/*
* Look for word "Version". Word after that
* is used as version.
*/
verpos = Find(txt,"Version")
if verpos ~= 0 then do
vers = Word(txt,verpos+1)
if vers = "" then do
/*
* If there is no version, try it in the
* next line
*/
verstat = "NextLine"
/*
* Delete word "version"
*/
txt = DelWord(txt,verpos,1)
end
else do
vers = Strip(vers,"T",".")
vers = Strip(vers,"T",",")
/*
* Stop searching for version strings
*/
verstat = "Done"
/*
* Delete word "version"
*/
txt = DelWord(txt,verpos,2)
end
end
end
Desc = Desc || " " || txt
end
return
/*
* DumpRecord writes the information about the program which is
* contained in ARexx vars to a Fiasco record
*/
DumpRecord:
if series = "" then do
F_RequestString 'Title "Read Fish" Text "What is the name*nof the PD library?"'
if rc = 0 then do
series = result
end
else do
series = "???"
end
end
if disk ~= "" & prog ~= "" & desc ~= "" then do
/*
* Send data to Fiasco
*/
F_AddRecord
F_SetFieldCont "DiskNumber" disk
F_SetFieldCont "ProgramName" prog
F_SetFieldCont "Desc" desc
F_SetFieldCont "Library" series
if vers ~= "" & symbol("vers") = "VAR" then F_SetFieldCont "Version" vers
if auth ~= "" & symbol("auth") = "VAR" then F_SetFieldCont "Author" auth
end
/*
* Clean up
*/
prog = ""
desc = ""
vers = ""
auth = ""
verstat = "None"
return
syntax:
failure:
say "Error" rc "in line" sigl ":" errortext(rc)
halt:
break_c:
say "Enter to continue"
pull dummy
F_UnlockGUI
exit