home *** CD-ROM | disk | FTP | other *** search
/ ANews 3 / AnewsCD3.iso / Script / ANews.rexx next >
OS/2 REXX Batch file  |  1999-10-06  |  13KB  |  462 lines

  1. /**********************************************************\
  2. **
  3. **      Interface du CD ANews
  4. **      ©1999 Frédéric RIGNAULT
  5. **
  6. \**********************************************************/
  7. VERSION = "$VER:v0.11 (12.06.1999)"
  8. VERSION = SUBSTR(VERSION,6)
  9.  
  10. ROOT="ANewsCD:"
  11.  
  12. FALSE=0
  13. TRUE=1
  14. TXTCOL="\0338"
  15. LASTCAT=0
  16. LASTREP=0
  17. LASTLIST=0
  18.  
  19. /* Open libs needed */
  20. options results
  21. IF EXISTS("libs:rexxsupport.library") THEN DO
  22.  IF ~SHOW("L","rexxsupport.library") THEN
  23.   IF ~ADDLIB("rexxsupport.library",0,-30,0) THEN EXIT
  24.  END
  25. ELSE EXIT
  26. IF EXISTS("libs:rexxreqtools.library") THEN DO
  27.  IF ~SHOW("L","rexxreqtools.library") THEN
  28.   IF ~ADDLIB("rexxreqtools.library",0,-30) THEN EXIT
  29.  END
  30. ELSE EXIT
  31. Say "Libs:OK"
  32.  
  33. if (show('p','ANEWS')) & (show('p','ASERV')) then do
  34.   address ANEWS SHOW
  35.   exit
  36. end
  37.  
  38. /* Open message Port Of Script */
  39. address rexx
  40. OPENPORT("ASERV")
  41.  
  42. /* Read Settings */
  43.  
  44. /*call DefaultPrefs*/
  45. /*call ConfSave*/
  46.  
  47. /* Open Muirexx */
  48.  
  49. call StartMUI
  50. call OpenGUI
  51. call InitAll
  52. call GestEvent
  53. address ANEWS QUIT
  54. exit
  55.  
  56. GestEvent:
  57. Do forever
  58.  address ANEWS
  59.  window ID ANEWS ATTRS MUIA_Window_Sleep FALSE
  60.  address REXX
  61.  gotit=0
  62.  do until gotit
  63.   call waitpkt(ASERV);packet=getpkt(ASERV)
  64.   gotit=(packet ~= null())
  65.  end
  66.  address ANEWS
  67.  window ID ANEWS ATTRS MUIA_Window_Sleep TRUE
  68.  address REXX;class=getarg(packet);reply(packet,0)
  69.  say class","LASTCAT","LASTREP","LASTLIST
  70.  address ANEWS
  71.  select
  72.    when class='ABOUT' then do
  73.      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 )
  74.    end
  75.    when class='QUIT' then break
  76.    when class='CATUPD' then call UpdateReps
  77.    when class='REPUPD' then call UpdateList
  78.    when class='LSTUPD' then call UpdateInfos
  79.    when class='AUTO' then call StartAuto
  80.    when class='GUIDE' then call ShowGuide
  81.    otherwise say class||"?"
  82.  end
  83. end
  84. return
  85.  
  86. InitAll:
  87. If open('f1',ROOT||"Arbre.ani",'r') then Do
  88.  i=0
  89.  j=0
  90.  Arbre.0=0
  91.  do forever
  92.    a=readln('f1')
  93.    if a="END" then break
  94.    if left(a,1)="+" then do
  95.      j=j+1
  96.      parse var a "+" b "," c
  97.      Arbre.i.0=j
  98.      Arbre.i.j.Titre=b
  99.      Arbre.i.j.Rep=c
  100.    end
  101.    else do
  102.      i=i+1
  103.      Arbre.0=i
  104.      Arbre.i.Titre=a
  105.      j=0
  106.      Arbre.i.0=j
  107.    end
  108.  end
  109.  a=close('f1')
  110.  End
  111.  
  112. address ANEWS
  113.  
  114. list ID CATS ATTRS MUIA_List_Quiet TRUE
  115. do i=1 to Arbre.0
  116.   list ID CATS INSERT POS MUIA_List_Insert_Bottom STRING TXTCOL||Arbre.i.Titre
  117. end
  118. list ID CATS ATTRS MUIA_List_Quiet FALSE MUIA_List_Active 0
  119. return
  120.  
  121. UpdateReps:
  122. list ID CATS ATTRS MUIA_List_Active
  123. i=result+1
  124. if LASTCAT=i then return
  125. LASTCAT=i
  126. list ID REPS STRING
  127. list ID REPS ATTRS MUIA_List_Quiet TRUE
  128. DO j=1 to Arbre.i.0
  129.   LIST ID REPS INSERT POS MUIA_List_Insert_Bottom STRING TXTCOL||Arbre.i.j.Titre
  130. end
  131. list ID REPS ATTRS MUIA_List_Quiet FALSE MUIA_List_Active 0
  132. LASTREP=0
  133. return
  134.  
  135. UpdateList:
  136. list ID CATS ATTRS MUIA_List_Active
  137. i=result+1
  138. list ID REPS ATTRS MUIA_List_Active
  139. j=result+1
  140.  
  141. if LASTREP=j then return
  142. LASTREP=j
  143.  
  144. /* Création des sous repertoires automatiquement */
  145.  
  146. repertoire=ROOT||Arbre.i.j.Rep
  147. If ~exists(repertoire) then do
  148.   Say "Création du repertoire"
  149.   a=left(repertoire,length(repertoire)-1)
  150.   address command 'makedir '||a
  151. end
  152.  
  153. list ID LIST STRING
  154. list ID LIST ATTRS MUIA_List_Quiet TRUE
  155.  
  156. i=0
  157. if exists(repertoire||'rep.ani') then do
  158.   If open('f1',repertoire||"rep.ani",'r') then Do
  159.     do forever
  160.       a=readln('f1')
  161.       if a="END" then break
  162.       parse var a b ',' c ',' d ',' e
  163.       i=i+1
  164.       contenu.0=i
  165.       contenu.i.fich=repertoire||b
  166.       contenu.i.base=repertoire||c
  167.       contenu.i.rep=repertoire||d
  168.       contenu.i.guide=repertoire||d||e
  169.       /*say '"'contenu.i.guide'"'*/
  170.       list ID LIST INSERT POS MUIA_List_Insert_Bottom STRING TXTCOL||b
  171.     end
  172.   a=close('f1')
  173.   end
  174. end
  175. list ID LIST ATTRS MUIA_List_Quiet FALSE
  176. if i>0 then do
  177.   list ID LIST ATTRS MUIA_List_Active 0
  178.   image ID AUTO ATTRS MUIA_Disabled False
  179. end
  180. else do
  181.   image ID GUIDE ATTRS MUIA_Disabled TRUE
  182.   image ID AUTO ATTRS MUIA_Disabled TRUE
  183. end
  184. LASTLIST=0
  185. return
  186.  
  187. UpdateInfos:
  188. list ID CATS ATTRS MUIA_List_Active
  189. i=result+1
  190. list ID REPS ATTRS MUIA_List_Active
  191. j=result+1
  192. list ID LIST ATTRS MUIA_List_Active
  193. k=result+1
  194.  
  195. if LASTLIST=k then return
  196. LASTLIST=k
  197. etat=FALSE
  198. fichier=Contenu.k.base
  199. if exists(fichier) then do
  200.   if LASTFILE~=fichier then etat=view(fichier)
  201.   lastfile=fichier
  202. end
  203. if ~(exists(fichier)) | etat=FALSE then do
  204.   fichier=Contenu.k.guide
  205.   if (exists(fichier)) & (UPPER(right(fichier,6))~='.GUIDE') then do
  206.     if LASTFILE~=fichier then do
  207.       view ID INFOS FILE fichier
  208.       etat=TRUE
  209.       lastfile=fichier
  210.     end
  211.   end
  212.   else do
  213.     view ID INFOS STRING ""
  214.     Lastfile=""
  215.   end
  216. end
  217. if (Contenu.k.guide~=lastfile) & (Contenu.k.guide~="") then do
  218.   image ID GUIDE ATTRS MUIA_Disabled FALSE
  219. end
  220. else do
  221.   image ID GUIDE ATTRS MUIA_Disabled TRUE
  222. end
  223. return
  224.  
  225. View:
  226. if exists(arg(1)) then do
  227.  if open('f1',arg(1),'r') then do
  228.    if open('f2',"T:info.txt","w") then do
  229.      etat=FALSE
  230.      do forever
  231.        a=readln('f1')
  232.        if eof('f1') then break
  233.        if etat=FALSE then do
  234.          if a=";infos" then etat=TRUE
  235.        end
  236.        else do
  237.          call writeln('f2',a)
  238.        end
  239.      end
  240.      call close('f2')
  241.    end
  242.    call close('f1')
  243.    view ID INFOS FILE "T:info.txt"
  244.  end
  245. end
  246. else do
  247.   etat=FALSE
  248.   view ID INFOS STRING ""
  249. end
  250. return(etat)
  251.  
  252. run:
  253. if exists(arg(1)) then do
  254.  if open('f1',arg(1),'r') then do
  255.    if open('f2',"T:script.run","w") then do
  256.      do forever
  257.        a=readln('f1')
  258.        if a=";infos" then break
  259.        call writeln('f2',a)
  260.      end
  261.      call close('f2')
  262.    end
  263.    call close('f1')
  264.    address command "run >nil: execute <>NIL: T:script.run"
  265.  end
  266. end
  267. return
  268.  
  269. ShowGuide:
  270. list ID LIST ATTRS MUIA_List_Active
  271. k=result+1
  272. fichier=Contenu.k.guide
  273. if (exists(fichier)) & (LASTFILE~=fichier)  then do
  274.   address COMMAND 'run <>NIL: Multiview '||fichier
  275. end
  276. return
  277.  
  278. StartAuto:
  279. list ID LIST ATTRS MUIA_List_Active
  280. k=result+1
  281. fichier=Contenu.k.base
  282. fichier2=Contenu.k.fich
  283. if exists(fichier) then do
  284.   if open('f1',fichier,'r') then do
  285.     b=readln('f1')
  286.     say b
  287.     if b=";manuel" then call run(fichier)
  288.     if b=";voir" then do
  289.       address command "run >NIL: "||ROOT||"c/Visage "||fichier2
  290.       /*address command "multiview "||fichier2*/
  291.     end
  292.     if b=";ecoute" then do
  293.       address command "rx >NIL: "||ROOT||"script/songplayer.rexx "||fichier2
  294.      /*address command "play16 <>NIL: "||fichier2*/
  295.     end
  296.     if b=";jouer" then do
  297.       say 'rx >NIL: '||ROOT||'script/hip.rexx "'||fichier2||'"'
  298.       address command "rx >NIL: "||ROOT||"script/hip.rexx "||fichier2
  299.     end
  300.     if b=";simple" then do
  301.       c=readln('f1')
  302.       address command "cd "||contenu.k.rep||'0a'x||"run <>NIL: "||c
  303.     end
  304.     if b=";html" then do
  305.       c=readln('f1')
  306.       address command "run >NIL: rx >NIL: "||ROOT||"script/Ibrowse.rexx "||c;
  307.     end
  308.     a=close('f1')
  309.   end
  310. end
  311. return
  312.  
  313. StartMUI:
  314. if ~(exists("ENVARC:mui/ANEWS.prefs")) then do
  315.   say "Copy Prefs"
  316.   address command "copy "||ROOT||"env/mui/ANEWS.prefs env:mui/"
  317. end
  318. address command "assign ADD fonts: "||ROOT||"fonts/"
  319. address command "path ADD "||ROOT||"c"
  320. address rexx
  321. muirexx= ROOT||'C/MUIRexx'
  322. if ~(Exists(muirexx)) then do; CALL rtezrequest "Ce n'est pas un CD ANews...",, "Message Plus";exit 20;end
  323. 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')
  324. address Command 'execute T:mmp.runscript'
  325. delete('T:mmp.runscript')
  326. address command 'run >NIL: rx '||ROOT||'script/autoclose.rexx'
  327. return
  328.  
  329. OpenGUI:
  330. address ANews
  331. ASLFR_DrawersOnly = 0x8008002F
  332. ASLFR_InitialDrawer = 0x80080009
  333. ASLFR_RejectIcons = 0x8008003C
  334. MUIA_Application_Active=0x804260ab
  335. MUIA_Application_Iconified = 0x8042a07f
  336. MUIA_ApplicationObject=0x8042d3ee
  337. MUIA_CycleChain = 0x80421ce7
  338. MUIA_ControlChar = 0x8042120b
  339. MUIA_Cycle_Active=0x80421788
  340. MUIA_Disabled=0x80423661
  341. MUIA_Font=0x8042be50
  342. MUIA_Gauge_Current=0x8042f0dd
  343. MUIA_Gauge_Divide=0x8042d8df
  344. MUIA_Gauge_Horiz=0x804232dd
  345. MUIA_Gauge_InfoText=0x8042bf15
  346. MUIA_Gauge_Max=0x8042bcdb
  347. MUIA_Group_ActivePage=0x80424199
  348. MUIA_Group_Columns=0x8042f416