home *** CD-ROM | disk | FTP | other *** search
- /* ReadFish.rexx
- * Copyright © 1995 Nils Bandener
- * $VER: ReadFish_rexx 3.1 (6.12.95)
- */
-
- /* 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
-
- tab = X2C("09")
- status = "None"
- verstat = "None"
- format = "None"
- notabs = 1
-
- F_RequestFile 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
-
- head = line
-
- disk = Word(head,Find(Upper(head),"DISK")+1)
-
- format = "Fish"
-
- status = "Disk"
-
- end
- else if Abbrev(line,"CONTENTS") then do
-
- head = line
-
- disk = Word(head,Find(Upper(head),"DISK")+1)
-
- status = "Disk"
-
- end
- else if Abbrev(line,"Below is a listing") then do
- nop
- end
- else if Abbrev(line,"Ausgabe:") then do
- issue = Word(line,2)
- say issue
- line = ReadLn("cont")
- format = "AmigaMag"
- disk = issue || "," || Word(line,2)
- say disk
- status = "Disk"
- end
- else if Abbrev(line,"Programm:") & format = "AmigaMag" then do
- prog = Word(line,2)
- status = "Program"
- findex = 1
- verstat = "Done"
- F_AddRecord
- F_SetFieldCont "DiskNumber" disk
- F_SetFieldCont "ProgramName" prog
- /* Rubrik */
- line = ReadLn("cont")
- /* Version */
- line = ReadLn("cont")
- ver = SubWord(line,2)
- if ver ~= "" then F_SetFieldCont "Version" ver
- /* Update */
- line = ReadLn("cont")
- line = ReadLn("cont")
- end
- else if Length(line) <= 1 then do
- if status = "Program" then status = "Disk"
- end
- else if Pos(tab,line) ~= 0 then do
- notabs = 0
- if status = "Disk" & format = "Fish" then do
- /* Read first line */
-
- status = "Program"
- findex = 1
- verstat = "None"
-
- prog = Left(line,Pos(tab,line)-1)
-
- if length(prog) <= 1 then do
- status = "End"
- end
- else do
- F_AddRecord
- F_SetFieldCont "DiskNumber" disk
- F_SetFieldCont "ProgramName" prog
-
- /* Fall through the next if */
- end
- end
- if status = "Program" then do
-
- /* Unfortunately Fiasco cannot handle multi-line
- * String-Fields. For this reason, several fields
- * are used.
- */
-
- txt = SubStr(line,Lastpos(tab,line)+1)
-
- if Abbrev(txt,"Author") | Abbrev(txt,"Autor") then do
- F_SetFieldCont "Author" SubWord(txt,2)
- end
- else do
- if verstat = "NextLine" then do
- ver = Word(txt,1)
- ver = Strip(ver,"T",D2C(44))
- ver = Strip(ver,"T",".")
- txt = DelWord(txt,1,1)
- F_SetFieldCont "Version" ver
- verstat = "Done"
- end
- else if verstat = "None" then do
- verpos = Find(txt,"Version")
- if verpos ~= 0 then do
- ver = Word(txt,verpos+1)
- if ver = "" then do
- verstat = "NextLine"
- txt = DelWord(txt,verpos,1)
- end
- else do
- verstat = "Done"
- txt = DelWord(txt,verpos,2)
- F_SetFieldCont "Version" ver
- end
- end
- end
- if findex <= 5 then F_SetFieldCont "Desc"||findex txt
- findex = findex + 1
- end
- end
- end
- /* Handling of Texts without tabs */
- else if notabs = 1 then do
- if status = "Disk" & Left(line,3) ~= " " then do
- /* Read first line */
-
- status = "Program"
- findex = 1
- verstat = "None"
-
- prog = Word(line,1)
- line = DelWord(line,1,1)
-
- if length(prog) <= 1 then do
- status = "End"
- end
- else do
- F_AddRecord
- F_SetFieldCont "DiskNumber" disk
- F_SetFieldCont "ProgramName" prog
-
- /* Fall through the next if */
- end
- end
- if status = "Program" then do
-
- /* Unfortunately Fiasco cannot handle multi-line
- * String-Fields. For this reason, several fields
- * are used.
- */
-
- txt = Strip(line)
-
- if Abbrev(txt,"Author") | Abbrev(txt,"Autor") then do
- F_SetFieldCont "Author" SubWord(txt,2)
- end
- else do
- if verstat = "NextLine" then do
- ver = Word(txt,1)
- ver = Strip(ver,"T",D2C(44))
- ver = Strip(ver,"T",".")
- txt = DelWord(txt,1,1)
- F_SetFieldCont "Version" ver
- verstat = "Done"
- end
- else if verstat = "None" then do
- verpos = Find(txt,"Version")
- if verpos ~= 0 then do
- ver = Word(txt,verpos+1)
- if ver = "" then do
- verstat = "NextLine"
- txt = DelWord(txt,verpos,1)
- end
- else do
- verstat = "Done"
- txt = DelWord(txt,verpos,2)
- F_SetFieldCont "Version" ver
- end
- end
- end
- if findex <= 5 then F_SetFieldCont "Desc"||findex txt
- findex = findex + 1
- end
- end
-
- end
- else do
- if status = "Program" then status = "Disk"
- end
- end
-
- dummy = Close("cont")
- end
- else say "Couldn`t open file"
-
- dummy = Close("f")
- Address Command "delete >NIL: t:fish"
- end
-
-