home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 384.lha / RxShell_v2.1 / RxShell < prev    next >
Text File  |  1990-06-11  |  7KB  |  229 lines

  1. /*---------------------------- Start REXX Source ----------------------------*/
  2.  
  3. /*   ****************************/
  4. /*   *      RxShell.rexx        */
  5. /*   * Execute selector program */
  6. /*   *   using ARexx v1.10      */
  7. /*   *         by               */
  8. /*   *     Steven D. Kapplin    */
  9. /*   *       05-MAY-90          */
  10. /*   *         v 2.10           */
  11. /*   ****************************/
  12.  
  13. /*   Portions adapted from Dan Schenck's print spooler.  Thanks, Dan!   */
  14.  
  15. /*   Modified by Steven D. Kapplin on 27-NOV-89 and 05-MAY-90           */
  16.  
  17. if ~show(L,'rexxsupport.library') then
  18.   rc = addlib('rexxsupport.library',0,-30,0)
  19.  
  20. if ~show(L,'rexxarplib.library') then
  21.   rc = addlib('rexxarplib.library',0,-30,0)
  22.  
  23. signal on BREAK_C
  24. true = 1
  25. false = 0
  26. name = "df0:||||"        
  27. parse arg cdir .
  28. if cdir = "?" then call banner
  29. if cdir = "" then cdir = "VD0:"
  30. pragma('D',cdir)
  31.  
  32. /* Command preferences - change strings in double quotes to the command */
  33. /* string desired.                                                      */
  34.  
  35. textviewer = "Sys:Tools/Type"
  36. pictureviewer = "Sys:Tools/Superview"
  37. unzoo = "c:archivers/Zoo"
  38. unarc = "c:archivers/Arc"
  39. unlzh = "c:archivers/LHarc"
  40. arcdir = "VD0:"
  41. playsound = ""
  42. player = "Dpaint:Play"
  43.  
  44. /*----------------------------------------------------------------------*/
  45.  
  46. do forever
  47.   do while(name = "df0:||||")
  48.     arg_flag = false
  49.     name = getfile(340,11,cdir,,'RxShell 2.0 - Select File')
  50.     if name = "" then call end_all()
  51.     nw = words(name)
  52.     parms = subword(name,2,nw-1)
  53.     name = word(name,1)
  54.     call parse_dir
  55.   end
  56.   address command
  57.   if index(cdir,":") = 0 then file2show = pragma('D') || cdir || "/" || name
  58.   else if right(cdir,1) ~= ":" then file2show = cdir || "/" || name
  59.        else file2show = cdir || name
  60.   call whatis
  61.   if rtc = 0 then ADDRESS COMMAND 'run' cmd || file2show || " " || parms
  62.   name = "df0:||||" 
  63. end
  64.  
  65. /*                            parse_dir Procedure                           */
  66. /*                                                                          */
  67. /*  Separate the directory portion of the file name if there is any from    */
  68. /*  the file name itself.  "cdir" will contain the new directory or be left */
  69. /*  untouched if there is no directory.  "name" will be modified to only    */
  70. /*  contain the file name itself or "df0:||||" if there is no file name.    */
  71.  
  72. parse_dir: procedure expose cdir name
  73.   if length(name) = 0 then
  74.     do /*  No name or directory  */
  75.       name = "df0:||||"
  76.       return
  77.     end
  78.   if ~exists(name) then
  79.     do /*  Bad directory/file name  */
  80.       name = "df0:||||"
  81.       return
  82.     end
  83.   i_colon = lastpos(":",name)
  84.   i_slash = lastpos("/",name)
  85.   if left(statef(name),1) = "F" then
  86.     do /*  This a file, not just a directory  */
  87.       if i_slash > 0 then
  88.         do /*  At least one subdirectory has been given  */   
  89.           cdir = substr(name,1,i_slash-1)
  90.           name = substr(name,i_slash+1)
  91.           return
  92.         end
  93.       if i_colon > 0 then
  94.         do /*  A main directory has been given  */
  95.           cdir = substr(name,1,i_colon)
  96.           name = substr(name,i_colon+1)
  97.           return
  98.         end
  99.       return
  100.     end
  101.   if i_slash > 0 then
  102.     do /*  A subdirectory with no file has been given  */
  103.       cdir = name
  104.       name = "df0:||||"
  105.       return
  106.     end
  107.   /*  A main directory or subdirectory only has been given  */
  108.   if i_colon = 0 then cdir = cdir || name
  109.   else cdir = name
  110.   name = "df0:||||"
  111.   return
  112.  
  113. /*                    WhatIs                        */
  114. /* This subroutine inspects the first few bytes of a file   */
  115. /* and determines the filetype from that information.  It   */
  116. /* returns a string which can be inserted into the command  */
  117. /* string sent to the Arexx command processor.              */
  118. /* Detects 15 different file types.                         */
  119.  
  120. whatis: 
  121. procedure expose file2show cmd player playsound textviewer pictureviewer rtc unarc unzoo unlzh arcdir
  122.  
  123. /*  Filetype identifiers            */
  124.  
  125.     EXE = "F3"                /* Executable */
  126.     PIC = "494C424D424D4844"        /* IFF Picture File */
  127.     XCEL = "4654585450534554"    /* Excellence! File */
  128.     PROW = "574F5244464F4E54"    /* ProWrite File */
  129.     ADV = "04F404F404F404F4"        /* Advantage Worksheet */
  130.     MAXI = "474C424C"            /* MaxiPlan Worksheet */
  131.     CAND = "4445434B414E4E4F"    /* CanDo Deck */
  132.     LZH = "2D6C68312D"            /* LHarc Archive */
  133.     ARC = "1A08"                /* Arc Archive */
  134.     ZOO = "2E1A0000DCA7C4FD"        /* Zoo Archive */
  135.     SND = "3853565856484452"        /* 8SVX Sound File */
  136.     PPG = "0708090D"            /* Professional Page 1.3 File */
  137.     PGS = "07231988000D0200"        /* PageStream 1.8 File */
  138.     RXX = ".rexx"                /* ARexx macro */
  139.     ANIM = "414E494D464F524D"    /* Anim File */
  140.  
  141. /*----------------------------------*/
  142.  
  143.     call open(f,file2show,'R')
  144.     instring = c2x(readch(f,24))
  145.     rtc = 0
  146.     call close(f)
  147.     select
  148.         when pos(RXX,file2show) > 0 then
  149.             cmd = ""
  150.         when substr(instring,7,2) = EXE then
  151.             cmd = ""
  152.         when substr(instring,17,16) = PROW then
  153.             cmd = "ProWrite:Prowrite "
  154.         when substr(instring,17,16) = PIC then
  155.             cmd = pictureviewer || "-c "
  156.         when substr(instring,17,16) = XCEL then
  157.             cmd = "Excellence!:Excellence! "
  158.         when substr(instring,1,16) = ADV then
  159.             cmd = "Advantage:Advantage "
  160.         when substr(instring,1,8) = MAXI then
  161.             cmd = "MaxiPlan:MaxiPlan-III "
  162.         when substr(instring,17,16) = ANIM then
  163.             cmd = player || " "
  164.         when substr(instring,17,16) = CAND then do
  165.             pragma('D','CanDo:')
  166.             cmd = "c:DeckRunner "
  167.             end
  168.         when substr(instring,17,16) = SND then
  169.             cmd = playsound || " "
  170.         when substr(instring,1,8) = PPG then
  171.             cmd = "PPage:PPage "
  172.         when substr(instring,1,16) = PGS then
  173.             cmd = "PageStream:PageStream "
  174.         when substr(instring,5,10) = LZH then do
  175.             pragma('D',arcdir)
  176.             call do_request()
  177.             if result = "OKAY" then cmd = unlzh || " -x x "
  178.             else    cmd = unlzh || " l "
  179.             end
  180.         when substr(instring,1,4) = ARC then do
  181.             pragma('D',arcdir)
  182.             call do_request()
  183.             if result = "OKAY" then cmd = unarc || " x "
  184.             else    cmd = unarc || " l "
  185.             end
  186.         when substr(instring,33,18) = ZOO then do
  187.             pragma('D',arcdir)
  188.             call do_request()
  189.             if result = "OKAY" then cmd = unzoo || " e// "
  190.             else    cmd = unzoo || " l "
  191.             end
  192.         otherwise do
  193.             do i = 1 to 32 by 2 
  194.                 s = substr(instring,i,2)
  195.                 if  s ~= "0A" & s ~= "0D" & s < "20" | s > "7F" then do
  196.                     rtc = 1
  197.                     cmd = ""
  198.                     return
  199.                 end
  200.             end
  201.             cmd = textviewer || " "
  202.         end
  203.     end
  204. return
  205.  
  206.  
  207. do_request: procedure expose result
  208. message = center('Unarc or List?',30)
  209. okgad = 'Unarc'
  210. cancgad = 'List'
  211.  
  212.     result = Request(360,144,message,,okgad,cancgad)
  213.  
  214. return result
  215.  
  216. BREAK_C:
  217.   call end_all()
  218. end_all: procedure
  219.   exit
  220.  
  221. banner:
  222.     Say "RxShell Ver. 2.1 by Steven D. Kapplin"
  223.     Say "Command Syntax: [Run] RxShell [?] | [<path>]"
  224.      Say "    ? displays this message"
  225.     Say "    <path> sets login path - default path ==> VD0:"
  226.     exit 5
  227.  
  228. /*----------------------------- End REXX Source -----------------------------*/
  229.