home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ANews 2
/
AnewsCD2.iso
/
Script
/
ANews.rexx
next >
Wrap
OS/2 REXX Batch file
|
1999-10-06
|
13KB
|
462 lines
/**********************************************************\
**
** Interface du CD ANews
** ©1999 Frédéric RIGNAULT
**
\**********************************************************/
VERSION = "$VER:v0.11 (12.06.1999)"
VERSION = SUBSTR(VERSION,6)
ROOT="ANewsCD:"
FALSE=0
TRUE=1
TXTCOL="\0338"
LASTCAT=0
LASTREP=0
LASTLIST=0
/* Open libs needed */
options results
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
IF EXISTS("libs:rexxreqtools.library") THEN DO
IF ~SHOW("L","rexxreqtools.library") THEN
IF ~ADDLIB("rexxreqtools.library",0,-30) THEN EXIT
END
ELSE EXIT
Say "Libs:OK"
if (show('p','ANEWS')) & (show('p','ASERV')) then do
address ANEWS SHOW
exit
end
/* Open message Port Of Script */
address rexx
OPENPORT("ASERV")
/* Read Settings */
/*call DefaultPrefs*/
/*call ConfSave*/
/* Open Muirexx */
call StartMUI
call OpenGUI
call InitAll
call GestEvent
address ANEWS QUIT
exit
GestEvent:
Do forever
address ANEWS
window ID ANEWS ATTRS MUIA_Window_Sleep FALSE
address REXX
gotit=0
do until gotit
call waitpkt(ASERV);packet=getpkt(ASERV)
gotit=(packet ~= null())
end
address ANEWS
window ID ANEWS ATTRS MUIA_Window_Sleep TRUE
address REXX;class=getarg(packet);reply(packet,0)
say class","LASTCAT","LASTREP","LASTLIST
address ANEWS
select
when class='ABOUT' then do
request ID ANEWS Title '"A propos du Navigateur ANews"' GADGETS "D'accord" STRING replacepat("Navigateur de CD ANews\nVersion %s\n©1999 Frédéric Rignault", "%s", VERSION )
end
when class='QUIT' then break
when class='CATUPD' then call UpdateReps
when class='REPUPD' then call UpdateList
when class='LSTUPD' then call UpdateInfos
when class='AUTO' then call StartAuto
when class='GUIDE' then call ShowGuide
otherwise say class||"?"
end
end
return
InitAll:
If open('f1',ROOT||"Arbre.ani",'r') then Do
i=0
j=0
Arbre.0=0
do forever
a=readln('f1')
if a="END" then break
if left(a,1)="+" then do
j=j+1
parse var a "+" b "," c
Arbre.i.0=j
Arbre.i.j.Titre=b
Arbre.i.j.Rep=c
end
else do
i=i+1
Arbre.0=i
Arbre.i.Titre=a
j=0
Arbre.i.0=j
end
end
a=close('f1')
End
address ANEWS
list ID CATS ATTRS MUIA_List_Quiet TRUE
do i=1 to Arbre.0
list ID CATS INSERT POS MUIA_List_Insert_Bottom STRING TXTCOL||Arbre.i.Titre
end
list ID CATS ATTRS MUIA_List_Quiet FALSE MUIA_List_Active 0
return
UpdateReps:
list ID CATS ATTRS MUIA_List_Active
i=result+1
if LASTCAT=i then return
LASTCAT=i
list ID REPS STRING
list ID REPS ATTRS MUIA_List_Quiet TRUE
DO j=1 to Arbre.i.0
LIST ID REPS INSERT POS MUIA_List_Insert_Bottom STRING TXTCOL||Arbre.i.j.Titre
end
list ID REPS ATTRS MUIA_List_Quiet FALSE MUIA_List_Active 0
LASTREP=0
return
UpdateList:
list ID CATS ATTRS MUIA_List_Active
i=result+1
list ID REPS ATTRS MUIA_List_Active
j=result+1
if LASTREP=j then return
LASTREP=j
/* Création des sous repertoires automatiquement */
repertoire=ROOT||Arbre.i.j.Rep
If ~exists(repertoire) then do
Say "Création du repertoire"
a=left(repertoire,length(repertoire)-1)
address command 'makedir '||a
end
list ID LIST STRING
list ID LIST ATTRS MUIA_List_Quiet TRUE
i=0
if exists(repertoire||'rep.ani') then do
If open('f1',repertoire||"rep.ani",'r') then Do
do forever
a=readln('f1')
if a="END" then break
parse var a b ',' c ',' d ',' e
i=i+1
contenu.0=i
contenu.i.fich=repertoire||b
contenu.i.base=repertoire||c
contenu.i.rep=repertoire||d
contenu.i.guide=repertoire||d||e
/*say '"'contenu.i.guide'"'*/
list ID LIST INSERT POS MUIA_List_Insert_Bottom STRING TXTCOL||b
end
a=close('f1')
end
end
list ID LIST ATTRS MUIA_List_Quiet FALSE
if i>0 then do
list ID LIST ATTRS MUIA_List_Active 0
image ID AUTO ATTRS MUIA_Disabled False
end
else do
image ID GUIDE ATTRS MUIA_Disabled TRUE
image ID AUTO ATTRS MUIA_Disabled TRUE
end
LASTLIST=0
return
UpdateInfos:
list ID CATS ATTRS MUIA_List_Active
i=result+1
list ID REPS ATTRS MUIA_List_Active
j=result+1
list ID LIST ATTRS MUIA_List_Active
k=result+1
if LASTLIST=k then return
LASTLIST=k
etat=FALSE
fichier=Contenu.k.base
if exists(fichier) then do
if LASTFILE~=fichier then etat=view(fichier)
lastfile=fichier
end
if ~(exists(fichier)) | etat=FALSE then do
fichier=Contenu.k.guide
if (exists(fichier)) & (UPPER(right(fichier,6))~='.GUIDE') then do
if LASTFILE~=fichier then do
view ID INFOS FILE fichier
etat=TRUE
lastfile=fichier
end
end
else do
view ID INFOS STRING ""
Lastfile=""
end
end
if (Contenu.k.guide~=lastfile) & (Contenu.k.guide~="") then do
image ID GUIDE ATTRS MUIA_Disabled FALSE
end
else do
image ID GUIDE ATTRS MUIA_Disabled TRUE
end
return
View:
if exists(arg(1)) then do
if open('f1',arg(1),'r') then do
if open('f2',"T:info.txt","w") then do
etat=FALSE
do forever
a=readln('f1')
if eof('f1') then break
if etat=FALSE then do
if a=";infos" then etat=TRUE
end
else do
call writeln('f2',a)
end
end
call close('f2')
end
call close('f1')
view ID INFOS FILE "T:info.txt"
end
end
else do
etat=FALSE
view ID INFOS STRING ""
end
return(etat)
run:
if exists(arg(1)) then do
if open('f1',arg(1),'r') then do
if open('f2',"T:script.run","w") then do
do forever
a=readln('f1')
if a=";infos" then break
call writeln('f2',a)
end
call close('f2')
end
call close('f1')
address command "run >nil: execute <>NIL: T:script.run"
end
end
return
ShowGuide:
list ID LIST ATTRS MUIA_List_Active
k=result+1
fichier=Contenu.k.guide
if (exists(fichier)) & (LASTFILE~=fichier) then do
address COMMAND 'run <>NIL: Multiview '||fichier
end
return
StartAuto:
list ID LIST ATTRS MUIA_List_Active
k=result+1
fichier=Contenu.k.base
fichier2=Contenu.k.fich
if exists(fichier) then do
if open('f1',fichier,'r') then do
b=readln('f1')
say b
if b=";manuel" then call run(fichier)
if b=";voir" then do
address command "run >NIL: "||ROOT||"c/Visage "||fichier2
/*address command "multiview "||fichier2*/
end
if b=";ecoute" then do
address command "rx >NIL: "||ROOT||"script/songplayer.rexx "||fichier2
/*address command "play16 <>NIL: "||fichier2*/
end
if b=";jouer" then do
say 'rx >NIL: '||ROOT||'script/hip.rexx "'||fichier2||'"'
address command "rx >NIL: "||ROOT||"script/hip.rexx "||fichier2
end
if b=";simple" then do
c=readln('f1')
address command "cd "||contenu.k.rep||'0a'x||"run <>NIL: "||c
end
if b=";html" then do
c=readln('f1')
address command "run >NIL: rx >NIL: "||ROOT||"script/Ibrowse.rexx "||c;
end
a=close('f1')
end
end
return
StartMUI:
if ~(exists("ENVARC:mui/ANEWS.prefs")) then do
say "Copy Prefs"
address command "copy "||ROOT||"env/mui/ANEWS.prefs env:mui/"
end
address command "assign ADD fonts: "||ROOT||"fonts/"
address command "path ADD "||ROOT||"c"
address rexx
muirexx= ROOT||'C/MUIRexx'
if ~(Exists(muirexx)) then do; CALL rtezrequest "Ce n'est pas un CD ANews...",, "Message Plus";exit 20;end
foo=open('OUT','T:mmp.runscript','W');foo=writeln('OUT',"FailAt 21");foo=writeln('OUT',"Stack 40000");foo=writeln('OUT',"run "||muirexx||" PORT ANEWS");foo=writeln('OUT',"waitforport ANEWS");foo=close('OUT')
address Command 'execute T:mmp.runscript'
delete('T:mmp.runscript')
address command 'run >NIL: rx '||ROOT||'script/autoclose.rexx'
return
OpenGUI:
address ANews
ASLFR_DrawersOnly = 0x8008002F
ASLFR_InitialDrawer = 0x80080009
ASLFR_RejectIcons = 0x8008003C
MUIA_Application_Active=0x804260ab
MUIA_Application_Iconified = 0x8042a07f
MUIA_ApplicationObject=0x8042d3ee
MUIA_CycleChain = 0x80421ce7
MUIA_ControlChar = 0x8042120b
MUIA_Cycle_Active=0x80421788
MUIA_Disabled=0x80423661
MUIA_Font=0x8042be50
MUIA_Gauge_Current=0x8042f0dd
MUIA_Gauge_Divide=0x8042d8df
MUIA_Gauge_Horiz=0x804232dd
MUIA_Gauge_InfoText=0x8042bf15
MUIA_Gauge_Max=0x8042bcdb
MUIA_Group_ActivePage=0x80424199
MUIA_Group_Columns=0x8042f416