/* Library Check on a selected volume
   V1.2 - 01/28/98 - © Age*/

if ~show('L',"rexxreqtools.library") then addlib('rexxreqtools.library',0,-30,0)

say "This ARexx-Script checks the libraries outside of the drawer LIBS:"
say "              V1.2 - 01/28/98 - © Heiko Schröder"
say "------------------------------------------------------------------"
say ""
say "This check can take a long time (volume-size specific)."
say "Do you want to continue (Y/N)?"; Pull Keyword
If upper(Keyword)~="Y" then exit

Device = rtfilerequest(,,"Pick a device",,"rtfi_volumerequest=vreqf_noassigns")
IF Device = "" then do 
   echo "Cancel"
   exit
END

say "I'm looking for libraries on "||Device
say "Please wait some minutes... Thanks."
if Device~="" then Device=d2c(34)||Device||d2c(34)

address command 'list ' device || 'p=#?.library to=Ram:VolLibCheck files lformat %s%s all'

say "Now I'm ready... Thanks for waiting."
say ""
say "Now i create the VolList.dvc for DVC."

Open("HDL","Ram:VolList.dvc","W")
Writeln("HDL","DVC1 (Don't change this line!)")
Writeln("HDL",";$VER: VolList.dvc by Heiko Schröder from LibGuide")
Writeln("HDL",";$EML: Heiko Schroeder <age@thepentagon.com>")
Writeln("HDL","")

IF ~OPEN('Infile',"ram:VolLibCheck","R") THEN EXIT 10      /*List-Result*/

DO WHILE 1				/* DO Forever - We'll EXIT on EOF) */
   Libfile = ReadLn('Infile')
	IF EOF('Infile') THEN leave
   say Libfile

   pos = max(pos(":",Libfile),lastpos("/",Libfile))   /*#?.library*/
   temp=Delstr(Libfile,1,pos)

   pos     =LastPos(".library",temp)                /* Version */
   LibfileK=Delstr(temp,pos+8)

   address command "search >ram:ListSearch search :"||LibfileK||" nonum Scripts/LibList.dvc"
   Open("list","ram:Listsearch","R")
   ScriptLib=readln("list")
   Close("list")

   If ScriptLib="" then do
      address command "search >ram:ListSearch search /"||LibfileK||" nonum Scripts/LibList.dvc"
      Open("list","ram:Listsearch","R")
      ScriptLib=readln("list")
      Close("list")
   End

   If ScriptLib~="" then do
      pos = max(pos(":",ScriptLib),lastpos("/",ScriptLib))   /*#?.library*/
      temp=Delstr(ScriptLib,1,pos)

      pos    =LastPos(".library",temp)                /* Version */
      ScriptVers=Delstr(temp,1,pos+8)
      writeln("HDL",Libfile||" "||ScriptVers)
   end
   else writeln("HDL",Libfile||" 0.0")
End

close("Infile")
close("HDL")
say "DVC checks the version strings of your libraries."
address command "DVC list=Ram:VolList.dvc"

say ""
say "You can find a list of your libraries at Ram:VolLibCheck."
address command "delete ram:VolList.dvc QUIET"
address command "delete ram:ListSearch QUIET"
say "Press »Return« to end."
PARSE PULL Keyword
exit
