home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / change2.zip / c.cmd next >
OS/2 REXX Batch file  |  1996-08-30  |  8KB  |  295 lines

  1. /* c.cmd, a program                                        */
  2. /*        to change drive and directory                    */
  3. /*        in a vera easy manner.                           */
  4. "@ echo off"
  5.  
  6.   Y="C"             /* Here type the drive letter on which  */
  7.                     /* the buffer files  of  c.cmd          */
  8.                     /* will be interim stored               */
  9.                     /* while  c.cmd  is running.            */
  10.   X=Y||":"||"\"
  11.  
  12.  
  13.   parse arg ziel
  14.   ziel=strip(ziel)
  15.  
  16.   if length(ziel) = 0
  17.   then do
  18.          "cd\"
  19.          signal E
  20.        end
  21.  
  22.   if length(ziel)=2
  23.   then do
  24.     ziel1 = substr(ziel,2,2)
  25.     if (COMPARE(ziel1,':')=0)
  26.     then do
  27.           ziel "2>" X"FehlLW2.DAT"
  28.       StrLW2=Charin(X"FehlLW2.DAT",1,7)
  29.        call charout(X"FehlLW2.DAT")
  30.  
  31.       if (COMPARE(StrLW2,"SYS0015") = 0)
  32.       then do
  33.         Call LWAnz substr(ziel, 1, 1)
  34.         RGW=1
  35.         signal E
  36.       end
  37.       "cd\"
  38.       signal E
  39.     end
  40.   end
  41.  
  42.   if ((Compare(substr(ziel,2,1),':')=0) & (Compare(substr(ziel,3,1),'\')=0))
  43.   then do
  44.          neuZiel=ziel
  45.          SIGNAL AQ
  46.        end
  47.  
  48.   if ((Compare(substr(directory(),2,1),':')=0) &,
  49.       (Compare(substr(directory(),3,1),'\')=0),
  50.        & (length(directory())>3))
  51.   then do
  52.          neuZiel=directory()||'\'||ziel
  53.          SIGNAL AQ
  54.        end
  55.  
  56.   neuZiel=directory()||ziel
  57.  
  58. AQ:
  59.   ziel=neuZiel
  60.  
  61.   parse var ziel w.1  '\' w.2  '\' w.3  '\',
  62.                  w.4  '\' w.5  '\' w.6  '\',
  63.                  w.7  '\' w.8  '\' w.9  '\',
  64.                  w.10 '\' w.11 '\' w.12
  65.  
  66.   if (length(w.1) > 0)
  67.   then do
  68.          w.1 "2>" X"FehlVz1.DAT"
  69.          "cd\"
  70.          StrVz1=Charin(X"FehlVz1.DAT",1,7);
  71.           call charout(X"FehlVz1.DAT")
  72.          if (COMPARE(StrVz1,"SYS0015") = 0)
  73.          then do
  74.                 Call LWAnz substr(w.1, 1, 1)
  75.                 signal E
  76.               end
  77.        end
  78.  
  79.   if (length(w.2) > 0)
  80.   then do
  81.          "cd" w.2 "2>" X"FehlVz2.DAT"
  82.          StrVz2=Charin(X"FehlVz2.DAT",1,7);
  83.           call charout(X"FehlVz2.DAT")
  84.          if (COMPARE(StrVz2,"SYS0003") = 0)
  85.          then do
  86.                 LwLw=substr(w.1, 1, 1)
  87.                 Call LWStamm LwLw w.2
  88.                 signal E
  89.               end
  90.        end
  91.  
  92.   if (length(w.3) > 0)
  93.   then do
  94.          "cd" w.3 "2>" X"FehlVz3.DAT"
  95.          StrVz3=Charin(X"FehlVz3.DAT",1,7);
  96.           call charout(X"FehlVz3.DAT")
  97.          if (COMPARE(StrVz3,"SYS0003") = 0)
  98.          then do
  99.                 Call VzUVz directory() w.3
  100.                 signal E
  101.               end
  102.        end
  103.  
  104.   if (length(w.4) > 0)
  105.   then do
  106.          "cd" w.4 "2>" X"FehlVz4.DAT"
  107.          StrVz4=Charin(X"FehlVz4.DAT",1,7);
  108.           call charout(X"FehlVz4.DAT")
  109.  
  110.          if (COMPARE(StrVz4,"SYS0003") = 0)
  111.          then do
  112.                 Call VzUVz directory() w.4
  113.                 signal E
  114.               end
  115.        end
  116.  
  117.   if (length(w.5) > 0)
  118.   then do
  119.          "cd" w.5 "2>" X"FehlVz5.DAT"
  120.          StrVz5=Charin(X"FehlVz5.DAT",1,7);
  121.           call charout(X"FehlVz5.DAT")
  122.  
  123.          if (COMPARE(StrVz5,"SYS0003") = 0)
  124.          then do
  125.                 Call VzUVz directory() w.5
  126.                 signal E
  127.               end
  128.        end
  129.  
  130.   if (length(w.6) > 0)
  131.   then do
  132.          "cd" w.6 "2>" X"FehlVz6.DAT"
  133.          StrVz6=Charin(X"FehlVz6.DAT",1,7);
  134.           call charout(X"FehlVz6.DAT")
  135.  
  136.          if (COMPARE(StrVz6,"SYS0003") = 0)
  137.          then do
  138.                 Call VzUVz directory() w.6
  139.                 signal E
  140.               end
  141.        end
  142.  
  143.   if (length(w.7) > 0)
  144.   then do
  145.          "cd" w.7 "2>" X"FehlVz7.DAT"
  146.          StrVz7=Charin(X"FehlVz7.DAT",1,7);
  147.           call charout(X"FehlVz7.DAT")
  148.  
  149.          if (COMPARE(StrVz7,"SYS0003") = 0)
  150.          then do
  151.                 Call VzUVz directory() w.7
  152.                 signal E
  153.               end
  154.        end
  155.  
  156.   if (length(w.8) > 0)
  157.   then do
  158.          "cd" w.8 "2>" X"FehlVz8.DAT"
  159.          StrVz8=Charin(X"FehlVz8.DAT",1,7);
  160.           call charout(X"FehlVz8.DAT")
  161.  
  162.          if (COMPARE(StrVz8,"SYS0003") = 0)
  163.          then do
  164.                 Call VzUVz directory() w.8
  165.                 signal E
  166.               end
  167.        end
  168.  
  169.   if (length(w.9) > 0)
  170.   then do
  171.          "cd" w.9 "2>" X"FehlVz9.DAT"
  172.          StrVz9=Charin(X"FehlVz9.DAT",1,7);
  173.           call charout(X"FehlVz9.DAT")
  174.  
  175.          if (COMPARE(StrVz9,"SYS0003") = 0)
  176.          then do
  177.                 Call VzUVz directory() w.9
  178.                 signal E
  179.               end
  180.        end
  181.  
  182.   if (length(w.10) > 0)
  183.   then do
  184.          "cd" w.10 "2>" X"FehlVz10.DAT"
  185.          StrVz10=Charin(X"FehlVz10.DAT",1,7);
  186.            call charout(X"FehlVz10.DAT")
  187.  
  188.          if (COMPARE(StrVz10,"SYS0003") = 0)
  189.          then do
  190.                 Call VzUVz directory() w.10
  191.                 signal E
  192.               end
  193.        end
  194.  
  195.   if (length(w.11) > 0)
  196.   then do
  197.          "cd" w.11 "2>" X"FehlVz11.DAT"
  198.          StrVz11=Charin(X"FehlVz11.DAT",1,7);
  199.            call charout(X"FehlVz11.DAT")
  200.  
  201.          if (COMPARE(StrVz11,"SYS0003") = 0)
  202.          then do
  203.                 Call VzUVz directory() w.11
  204.                 signal E
  205.               end
  206.        end
  207.  
  208.   if (length(w.12) > 0)
  209.   then do
  210.          "cd" w.12 "2>" X"FehlVz12.DAT"
  211.          StrVz12=Charin(X"FehlVz12.DAT",1,7);
  212.            call charout(X"FehlVz12.DAT")
  213.  
  214.          if (COMPARE(StrVz12,"SYS0003") = 0)
  215.          then do
  216.                 Call VzUVz directory() w.12
  217.                 SIGNAL E
  218.               end
  219.        end
  220.  
  221. E:
  222. "del" X"Fehl*.DAT 1>NUL 2>NUL"
  223. EXIT
  224.  
  225. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Procedures %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
  226.  
  227. LWAnz:
  228.   parse arg Param
  229.   Call CsrAttrib "High";   Call Color "yellow","black"
  230.   say
  231.   Call Charout,"   A drive  "
  232.                            Call Color "cyan"
  233.   Call Charout,param
  234.                            Call Color "yellow","black"
  235.   Call Charout,"  does not exist on this computer"
  236.   say
  237.   Call CsrAttrib "Normal"; Call Color "white","black"
  238.   Return
  239.  
  240. VzUVz:
  241.   parse arg param
  242.   parse value param with param1 param2
  243.   Call CsrAttrib "High";   Call Color "yellow","black"
  244.   say
  245.   Call Charout,"   A subdirectory  "
  246.                            Call Color "cyan"
  247.   Call Charout,param2
  248.                            Call Color "yellow","black"
  249.   say
  250.   Call Charout,"   does not exist  "
  251.   say
  252.   Call Charout,"     in directory  "
  253.                            Call Color "cyan"
  254.   Call Charout,param1
  255.   say
  256.   Call CsrAttrib "Normal"; Call Color "white","black"
  257.   Return
  258.  
  259. LWStamm:
  260.   parse arg param
  261.   parse value param with param1 param2
  262.   Call CsrAttrib "High";   Call Color "yellow","black"
  263.   say
  264.   Call Charout,"             A directory  "
  265.                            Call Color "cyan"
  266.   Call Charout,param2
  267.   say
  268.                            Call Color "yellow"
  269.   Call Charout,"          does not exist  "
  270.   say
  271.   Call Charout,"   in the root directory  "
  272.   say
  273.   Call Charout,"                of drive  "
  274.                            Call Color "cyan"
  275.   Call Charout,param1
  276.   say
  277.   Call CsrAttrib "Normal"; Call Color "white","black"
  278.   Return
  279.  
  280. /* %%%%%%%%%%%%%%%%%%%%%%%%%%% ANSI-Procedures %%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
  281.  
  282. Color: Procedure
  283. arg F,B
  284. Colors = "BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE"
  285. return CHAROUT(,D2C(27)"["WORDPOS(F,COLORS)+29";"WORDPOS(B,COLORS)+39";m")
  286.  
  287. CsrAttrib: Procedure
  288. Arg A
  289. attr = "NORMAL HIGH LOW ITALIC UNDERLINE BLINK RAPID REVERSE"
  290. return CHAROUT(,D2C(27)"["WORDPOS(A,ATTR) - 1";m")
  291.  
  292. EndAll:
  293. Call Color "White","Black"
  294. CALL CsrAttrib "Normal"
  295.