home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ANews 3
/
AnewsCD3.iso
/
Script
/
Lhaction.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-10-06
|
14KB
|
491 lines
/************************************/
/* */
/* Lhaction V1.0 du 11/01/1999 */
/* Créer par Frédéric RIGNAULT */
/* Fortement inspiré par LHA-GUI */
/* Version adaptée pour ANews */
/* */
/************************************/
parse arg '"' currentfile '"'
if (currentfile = "") then parse arg currentfile
if currentfile = "" then currentfile="Caches:Download/"
extractdir="RAM:"
options results
/* Open libs needed */
IF EXISTS("libs:rexxsupport.library") THEN DO
IF ~SHOW("L","rexxsupport.library") THEN
IF ~ADDLIB("rexxsupport.library",0,-30,0) THEN EXIT
END
ELSE EXIT
/* Open message Port Of Script */
address rexx
nb=1
do while show("P","LHSER"||nb)
nb=nb+1
end
server="LHSER"||nb
gui="LHACT"||nb
say server
say gui
OPENPORT(server)
/*if currentfile="" then currentfile=""*/
call locale
call opengui
call readlist(currentfile)
tree=""
call listing("")
call waiting
address value gui;QUIT
exit
waiting:
do forever
if arc=0 then call info(getready)
if arc=1 then do
if tree="" then call info(infosize||unpacksize)
end
address value gui;
window ID LHACT ATTRS MUIA_Window_Sleep FALSE
address REXX
gotit=0
do until gotit
call waitpkt(server);packet=getpkt(server)
gotit=(packet ~= null())
end
address value gui;
window ID LHACT ATTRS MUIA_Window_Sleep TRUE
address REXX;class=getarg(packet);reply(packet,0)
say class
if class="QUIT" then break
if left(class,4)="DROP" then do
parse var class a ' ' b
if right(b,1)="/" | right(b,1)=":" then do
extractdir=b
address value gui
popasl ID DIR CONTENT extractdir
end
else do
currentfile=b
address value gui
popasl ID FILE CONTENT currentfile
class="FILE"
end
end
if class="PARENT" then do
say tree
if tree~="" then do
do i=length(tree)-1 to 2 by -1
if substr(tree,i,1)="/" then break
end
say i
if i=1 then tree=""
if i>1 then tree=left(tree,i)
say tree
call listing(tree)
end
end
if class="FILE" then DO /* */
address value gui
popasl ID FILE
currentfile=result
call readlist(currentfile)
tree=""
call listing(tree)
end
if class="DIR" then do
popasl ID DIR
extractdir=resul
end
if class="ROOT" then do
tree=""
call listing(tree)
end
if class="LSTUPD" then do
address value gui
list ID ARCH ATTRS MUIA_List_Active
if result~=4294967295 then do
list ID ARCH POS result
say result
parse var result num "," a "," d "," t
call info(name.num)
end
end
if class="COPYACT" then do
address value gui
list ID ARCH ATTRS MUIA_List_Active
if result~=4294967295 then do
list ID ARCH POS result
say result
parse var result num "," a "," d "," t
address ASERV ADDOP
call delay(25)
address ANEWS string ID RFILE CONTENT name.num
address ASERV RFILE
end
end
if class="LIST" then do
say "List..."
address value gui
list ID ARCH ATTRS MUIA_List_Active
list ID ARCH POS result
say result
parse var result num "," a "," d "," t
say name.num
say t
If right(t,1)="/" then do
SAY "Dir action"
tree=tree||t
call listing(tree)
end
else do
call info(showfile||t)
t2=tree||t
if type=".LHA" | type=".LZH" then do
address command "lha >NIL: e -m -q """||currentfile||""" "||t2||" T:"
address command "run >NIL: sys:utilities/Multiview >NIL: T:"||t2
end
if type=".LZX" then do
address command "lzx >NIL: e -m """||currentfile||""" "||t2||" T:"
address command "run >NIL: sys:utilities/Multiview >NIL: T:"||t
end
if type=".ZIP" then do
address command "unzip >NIL: -o """||currentfile||""" "||t2||" -d T:"
address command "run >NIL: sys:utilities/Multiview >NIL: T:"||t2
end
end
end
if class="EXTRACT" then do
address value GUI
ligne=0
if open('f1','T:list'||gui,'w') then do
say 'Write...'
do forever
list ID ARCH
b=result
say b
if b="" then break
ligne=ligne+1
parse var b n "," a "," d "," t
if right(t,1)="/" then
do
t=tree||t
say "AddRep..."||t
call addrep(t)
end
else do
say "Add File..."||name.n
call writeln('f1',name.n)
end
end
call close('f1')
end
call info(extracting)
if ligne=0 then
do
if type=".LHA" | type=".LZH" then address command "lha >CON: x """||currentfile||""" "||extractdir
if type=".LZX" then address command "lzx >CON: x -F """||currentfile||""" "||extractdir
if type=".ZIP" then address command "unzip >CON: """||currentfile||""" -d "||extractdir
end
else do
if type=".LHA" | upper(right(currentfile,4))=".LZH" then address command "lha x -r """||currentfile||""" @T:list"||gui||" "||extractdir
if type=".LZX" then address command "lzx >CON: x -F """||currentfile||""" "||extractdir
if type=".ZIP" then address command "unzip >CON: """||currentfile||""" -d "||extractdir
end
end
end
return
addrep:
lb=length(arg(1))
nom=upper(arg(1))
do i=1 to lines
if upper(left(name.i,lb))=nom then do
call writeln('f1',name.i)
say name.i
end
end
return
listing:
lbuf=0
dbuf=0
last=""
base=arg(1)
lb=length(base)
address value gui;list ID ARCH string
if lines=0 then return
list ID ARCH ATTRS MUIA_List_Quiet TRUE
do i=1 to lines
nom=name.i
if lb~=0 then do
if upper(left(nom,lb))=upper(base) then do
nom=RIGHT(nom,length(nom)-lb)
end
else do
nom=""
end
end
if nom~="" then do
actuel=partone(nom)
if right(actuel,1)="/" then
do
j=dbuf+1
if dbuf>0 then do
do j=1 to dbuf
if upper(dirbuf.j)=upper(tree||actuel) then break
end
end
if j=dbuf+1 then do
dbuf=dbuf+1
dirbuf.dbuf=tree||actuel
lbuf=lbuf+1
buffer.lbuf=actuel
buffer2.lbuf="DIR"
list ID ARCH INSERT POS MUIV_List_Insert_Bottom STRING i||",\0336\033b"||actuel||",\033b\033r\0335"||direntry||","||actuel
/*list ID ARCH INSERT POS MUIV_List_Insert_Bottom STRING "\033b\0336"||actuel||",\033b\033r\0335"||direntry*/
end
end
else do
lbuf=lbuf+1
buffer.lbuf=actuel
buffer2.lbuf=size.i
list ID ARCH INSERT POS MUIV_List_Insert_Bottom STRING i||","||actuel||",\033r"||size.i||","||actuel
end
end
end
list ID ARCH ATTRS MUIA_List_Quiet FALSE
return
partone:
n=arg(1)
parse var n a '/' b
if length(n)~=length(a) then a=a||"/"
return a
readlist:
lines=0
arc=0
if right(arg(1),1)=":" | right(arg(1),1)="/" then return
if ~exists(arg(1)) then return
call info(readlist)
type=upper(right(arg(1),4))
if type=".LHA" | type=".LZH" then call readlha(arg(1))
if type=".LZX" then call readlzx(arg(1))
if type=".ZIP" then call readzip(arg(1))
if arc=0 then do
address command "run >NIL: sys:utilities/Multiview >NIL: """||arg(1)||""""
end
return
readlha:
address command "lha >T:"||gui||" v """||arg(1)||""""
say 'T:'||gui
if open('f1','T:'||gui,'r') then do
say 'READ...'
a=readln('f1') /* Lha... */
a=readln('f1') /* copy...*/
a=readln('f1') /* copy...*/
a=readln('f1') /* Blank */
a=readln('f1') /* Unable ou Listing */
if left(a,4)~='List' then say 'NO LISTING!'
a=readln('f1') /* Blank ou Original */
if left(a,8)~='Original' then say 'no Original'
a=readln('f1') /* --------- */
if left(a,8)~="--------" then say 'no --------'
do forever
a=readln('f1')
if left(a,8)="--------" then break
if left(a,1)~=":" then do
parse var a Taille Compact Ratio Dat Time Name
lines=lines+1
name.lines=right(name,length(name)-2)
size.lines=taille
end
end
a=readln('f1')
parse var a unpacksize b
call close('f1')
arc=1
end
return
readlzx:
address command "lzx >T:"||gui||" l """||arg(1)||""""
if open('f1','T:'||GUI,'r') then do
say 'READ...'
a=readln('f1')
a=readln('f1') /* LZX Eva... */
a=readln('f1') /* Copyright...*/
a=readln('f1') /* Commercial... */
a=readln('f1')
a=readln('f1') /* Viewing or ** */
if left(a,4)~='View' then say 'NO LISTING!'
a=readln('f1')
a=readln