home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / DSHL11.ZIP / DEVSHELL.CMD < prev    next >
OS/2 REXX Batch file  |  1991-12-22  |  29KB  |  843 lines

  1. /*------------------------------------------------------*/
  2. /*         DevShell - Developers Shell                  */
  3. /*         Version 1.0 $Revision: 1.10 $                 */
  4. /*     (C) Copyright 1991 Frank V. Castellucci          */
  5. /*             All Rights Reserved                      */
  6. /*------------------------------------------------------*/
  7.  
  8. /*------------------------------------------------------*/
  9. /*  Global variable areas                               */
  10. /*------------------------------------------------------*/
  11.  
  12. Config.maxcfg   = 0;
  13. Config.maxalias = 0;
  14. Config.maxvol   = 0;
  15.                 
  16. CntlShell.          = "";
  17. CntlShell.usedalias = 0;
  18. OpenFiles.          = "";
  19.  
  20. Commands.num    = 0;
  21. Commands.cur    = "";
  22.  
  23. /*  Pull command line arguments             */
  24.  
  25. Parse Upper Arg CommandLine
  26.  
  27. /*  Fetch count of arguments                */
  28.  
  29. argc = GetArgC(CommandLine);
  30.  
  31. if(argc > 0) then do
  32.     Commands.cur = CommandLine;
  33.     end
  34.  
  35. /*------------------------------------------*/
  36. /*  If the configuration file inits ok, loop*/
  37. /*  through user input until the exit or    */
  38. /*  quit command is entered.                */
  39. /*------------------------------------------*/
  40.  
  41. if(InitConfig(argc,CommandLine) = "READY:") then do
  42.     do until (i=0)
  43.         i=FetchInput();
  44.         if( i > 0 & i <> 'ffff'x) then do
  45.             r=dispatch(i,Commands.cur);
  46.             end
  47.         end
  48.     Call Header;
  49.     End
  50.     
  51. else do
  52.     say "Error in configuration file management"
  53.     end
  54.     
  55. /*------------------------------*/
  56. /* The only exit in the house   */
  57. /*------------------------------*/
  58.     
  59. exit i;
  60.  
  61. /*------------------------------------------------------*/
  62. /*  Displays Header Information                         */
  63. /*------------------------------------------------------*/
  64. Header: procedure
  65. say; say;
  66.  
  67. loop = 1;
  68. do until LEFT(sourceline(loop),4) = "    "
  69.     String = sourceline(loop);
  70.     if(LEFT(String,4) = "more" | LEFT(String,4) = "More") then do
  71.         r=lineout(,"Press [ENTER] to continue");
  72.         linein()
  73.         end
  74.     else do
  75.         r=lineout(,String);
  76.         end
  77.     loop = loop+1;
  78.     end
  79.  
  80. return;
  81.  
  82. /*------------------------------------------------------*/
  83. /*  Routine to fetch number of arguments passed by user */
  84. /*------------------------------------------------------*/
  85.  
  86. GetArgC: procedure 
  87. BigString = Arg(1)
  88. count = 0
  89. do while(BigString <> "")
  90.     Parse Var BigString Drop BigString
  91.     count = count+1
  92.     end
  93.     
  94. return count;
  95.  
  96. /*------------------------------------------------------*/
  97. /*  Routine to fetch additional command line arguments  */
  98. /*  Here argv. is exposed to pass the information to    */
  99. /*  other functions either locally or externally        */
  100. /*------------------------------------------------------*/
  101.  
  102. FetchInput: procedure expose Commands.
  103.  
  104. r=charout(,"0d0a"x"[ready]: ")
  105. parse value linein() with Ops
  106.  
  107. i = GetArgC(Ops);
  108.  
  109. if( i > 0) then do
  110.     PARSE UPPER VAR Ops argv0 rest
  111.     if(argv0 = 'EXIT' | argv0 = 'QUIT') then do
  112.         i = 0;
  113.         end
  114.     end
  115.  
  116.     /*  Otherwise the enter key was hit with no input   */
  117.     
  118. else do
  119.     i = 'ffff'x;
  120.     end
  121.     
  122. if( i > 0 & i <> 'ffff'x) then do
  123.     t = Commands.num
  124.     Commands.t = Ops
  125.     Commands.cur = Ops
  126.     Commands.num = t+1
  127.     end
  128.         
  129. return i;
  130.  
  131. /*------------------------------------------------------*/
  132. /*  Dispatch what the user wanted to call us for        */
  133. /*  Argc    -   Counts of words in entry string         */
  134. /*  Ops     -   Fully entered string                    */
  135. /*  Spare   -   Same, I forget why?                     */
  136. /*------------------------------------------------------*/
  137.  
  138. DisPatch: procedure expose Config. Commands. CntlShell.
  139.  
  140. argc    = Arg(1)
  141. Ops     = Arg(2)
  142. spare   = Arg(2)
  143.  
  144. HlpStr = '@call 'CntlShell.Help'\devman()';  
  145.  
  146.     /*------------------------------------------------------*/
  147.     /*    Parse out arguments into automatic array          */
  148.     /*------------------------------------------------------*/
  149.     
  150.     i = 0
  151.     do while ( i < argc )
  152.         if( i = 0 ) then do
  153.             parse var Ops argv.i Ops
  154.             end
  155.         else do
  156.             parse var Ops argv.i Ops
  157.             end
  158.         
  159.         i = i+1
  160.         end
  161.     
  162.     
  163.     results = 1;                        /*  Return status       */
  164.     uparg0  = translate(argv.0);        /*  Force upper case    */
  165.     
  166.     select  
  167.         /*--------------------------------------------------------------*/
  168.         /*  If the argument is a number, we assume a stacked command    */
  169.         /*--------------------------------------------------------------*/
  170.         when (datatype( argv.0 ) = "NUM") then do
  171.             Commands.num = Commands.num - 1;         
  172.             if(argv.0 < Commands.num) then do
  173.                 t = argv.0
  174.                 results = dispatch(GetArgC(Commands.t),Commands.t)
  175.                 end
  176.             else do
  177.                 r=lineout(,argv.0 "not in command stack");
  178.                 end
  179.             end
  180.             
  181.         /*--------------------------------------------------------------*/         
  182.         /*  Direct call to the operating system, we first remove 'OS'   */
  183.         /*--------------------------------------------------------------*/
  184.         
  185.         when(uparg0 = 'OS') then do
  186.             parse var spare dump spare
  187.             spare
  188.             results = 0;
  189.             end
  190.             
  191.         /*--------------------------------------------------------------*/ 
  192.         /*  Query Options Command                                       */
  193.         /*--------------------------------------------------------------*/ 
  194.         
  195.         when (argv.0 = "?" | uparg0 = "HELP") then do
  196.             if(argc > 1) then do
  197.                 push argv.1;
  198.                 end
  199.             else do
  200.                 push "";
  201.                 end
  202.             HlpStr;
  203.             end
  204.             
  205.         /*--------------------------------------------------------------*/ 
  206.         /*  Display alias list as currently assigned                    */
  207.         /*--------------------------------------------------------------*/ 
  208.         
  209.         when ( uparg0 = 'ALIAS' ) then do
  210.             i=0
  211.             do while(i < Config.maxalias)
  212.                 t = Config.i
  213.                 string = LEFT(Config.i,15) "=" Config.i.t
  214.                 r=lineout(,string);
  215.                 i = i+1
  216.                 end
  217.             end
  218.             
  219.         /*--------------------------------------------------------------*/   
  220.         /*  Change or add an alias string                               */
  221.         /*--------------------------------------------------------------*/
  222.         
  223.         when ( uparg0 = 'ASET' ) then do
  224.             if(argc > 2) then do
  225.                 i=0;
  226.                 t=0;
  227.                 Ops = argv.1;
  228.                 parse var spare dummy0 dummy1 argv.2 
  229.                 
  230.                 do while( i < Config.maxalias)
  231.                     if(compare(Config.i,Ops) = 0) then do
  232.                         Config.i.Ops = argv.2
  233.                         i = Config.maxalias;
  234.                         t = 1;
  235.                         end
  236.                     i = i+1;
  237.                     end
  238.                     
  239.                 if( t = 0 ) then do
  240.                     i = Config.maxalias;
  241.                     Config.i = Ops;
  242.                     Config.i.Ops = argv.2;
  243.                     i = i+1;
  244.                     Config.maxalias = i;
  245.                     end
  246.                 end
  247.             else do
  248.                 push 'ASET';
  249.                 HlpStr;
  250.                 end
  251.             end
  252.             
  253.         /*--------------------------------------------------------------*/ 
  254.         /*  Display configuration list as current                       */
  255.         /*--------------------------------------------------------------*/         
  256.         
  257.         when ( uparg0 = 'CONFIG' ) then do
  258.             i = 0;
  259.             do while(i < Config.maxcfg)
  260.                 r=lineout(,LEFT("Config."Config.FUNCTIONS.i,15) "=",
  261.                                          Config.FUNCTIONS.i.0);
  262.                 i = i+1;
  263.                 end
  264.             end
  265.         
  266.         /*--------------------------------------------------------------*/ 
  267.         /*  Change or add a configuration string                        */
  268.         /*--------------------------------------------------------------*/ 
  269.         
  270.         when ( uparg0 = 'CSET') then do
  271.    
  272.             if(argc > 2) then do
  273.                 parse var spare dummy Ops;
  274.                 CfgCmd = "";
  275.                 CfgCmd = CheckConfig(Ops);
  276.             
  277.                 if( CfgCmd <> "") then do
  278.                     CfgCmd = translate(argv.1);
  279.                     t=0;
  280.                     do while( Config.FUNCTIONS.t <> CfgCmd )
  281.                         t = t+1;
  282.                         end
  283.                     Config.FUNCTIONS.t.0 = argv.2;
  284.                     end          
  285.                 else do
  286.                     CfgCmd = translate(argv.1);
  287.                     t=Config.maxcfg;
  288.                     Config.FUNCTIONS.t = CfgCmd;
  289.                     Config.FUNCTIONS.t.0 = argv.2;
  290.                     Config.maxcfg = Config.maxcfg + 1;
  291.                     end
  292.                 end
  293.             else do
  294.                 push 'CSET';
  295.                 HlpStr;
  296.                 end
  297.             end
  298.             
  299.         /*--------------------------------------------------------------*/ 
  300.         /*  Display the command stack                                   */
  301.         /*--------------------------------------------------------------*/ 
  302.         
  303.         when ( uparg0 = 'COMSTACK' | uparg0 = 'COMS') then do
  304.             if(argc < 2) then do
  305.                 i = 0
  306.                 do while( i < Commands.num)
  307.                     string = LEFT(i,5)" "Commands.i
  308.                     r=lineout(,string);
  309.                     i = i+1
  310.                     end
  311.                 end
  312.             else do
  313.                 
  314.                 /*------------------------------------------*/
  315.                 /*  The '.' parameter resets the stack to 0 */
  316.                 /*------------------------------------------*/
  317.                 
  318.                 if(argv.1 = '.') then do
  319.                     Commands.num = 0;
  320.                     end 
  321.                 end
  322.             end
  323.  
  324.         /*--------------------------------------------------------------*/ 
  325.         /*  Change to directory listed in volser list, or do direct     */
  326.         /*--------------------------------------------------------------*/ 
  327.         
  328.         when ( uparg0 = 'GO' ) then do
  329.             if(argc > 1) then do
  330.                 NewVol = CheckVolumes(argv.1);
  331.                 if(NewVol <> "") then do
  332.                     CntlShell.CurDir = directory(NewVol);
  333.                     end
  334.                 else do
  335.                     NewVol = directory(argv.1);
  336.                     if(NewVol <> "" ) then do
  337.                         CntlShell.CurDir = NewVol;
  338.                         
  339.                         end
  340.                     else do
  341.                         r=lineout(,"VOL assignment "argv.1" not found");
  342.                         r=lineout(,"and directory change returned error");
  343.                         end
  344.                     end
  345.                 end
  346.             else do
  347.                 push 'GO';
  348.                 HlpStr;
  349.                 end
  350.             end
  351.             
  352.         /*--------------------------------------------------------------*/     
  353.         /*  Go to directory listed in the config file                   */
  354.         /*--------------------------------------------------------------*/ 
  355.         
  356.         when ( uparg0 = 'HOME' ) then do
  357.             CntlShell.CurDir = directory(CntlShell.Home);
  358.             end
  359.             
  360.         /*--------------------------------------------------------------*/
  361.         /*  Show general information about session parameters           */
  362.         /*--------------------------------------------------------------*/
  363.         
  364.         when ( uparg0 = 'INFO' ) then do
  365.             r=lineout(,' '); 
  366.             r=lineout(,'Current Directory 'CntlShell.CurDir);
  367.             r=lineout(,'Home Directory    'CntlShell.Home);
  368.             r=lineout(,'Help Directory    'CntlShell.Help);
  369.             r=lineout(,' ');
  370.             r=lineout(,'Config File       'CntlShell.Cfg);
  371.             r=lineout(,'Apps Configured = 'Config.maxcfg);
  372.             r=lineout(,'Vols Configured = 'Config.maxvol);
  373.             r=lineout(,'Alias Execs     = 'Config.maxalias);
  374.             r=lineout(,' ');
  375.             r=lineout(,'Command stack   = 'Commands.num);
  376.             end
  377.         
  378.         /*--------------------------------------------------------------*/ 
  379.         /*  Reinitialize the configuration file, assumed edited         */
  380.         /*--------------------------------------------------------------*/ 
  381.         
  382.         when (uparg0 = "REINIT") then do
  383.             results = InitConfig(0);
  384.             end
  385.         
  386.         /*--------------------------------------------------------------*/ 
  387.         /*  List volumes assigned from configuration file, or session   */
  388.         /*--------------------------------------------------------------*/ 
  389.         
  390.         when ( uparg0 = 'VOLUMES' ) then do
  391.             i=0;
  392.             do while(i < Config.maxvol)
  393.                 r=lineout(,LEFT("VOL."Config.VOLSERS.i,15) "=",
  394.                                         Config.VOLSERS.i.0);
  395.                 i = i+1;
  396.                 end
  397.             end
  398.             
  399.         /*--------------------------------------------------------------*/     
  400.         /*  Change or add volume look-aside assignment                  */
  401.         /*--------------------------------------------------------------*/ 
  402.         
  403.         when ( uparg0 = 'VSET') then do
  404.             if(argc > 2) then do
  405.                 NewVol = "";
  406.                 NewVol = CheckVolumes(argv.1);
  407.                 if(NewVol <> "") then do
  408.                     t=0;
  409.                     do while(Config.VOLSERS.t <> argv.1)
  410.                         t=t+1;
  411.                         end
  412.                     Config.VOLSERS.t.0 = argv.2;
  413.                     end
  414.                 else do
  415.                     t = Config.maxvol;
  416.                     Config.VOLSERS.t = argv.1;
  417.                     Config.VOLSERS.t.0 = argv.2;
  418.                     Config.maxvol = Config.maxvol +1;
  419.                     end
  420.                 end
  421.             else do
  422.                 push 'ASET';
  423.                 HlpStr;
  424.                 end
  425.             end
  426.         
  427.         /*--------------------------------------------------------------*/ 
  428.         /*  Falling through we check configuration cross-reference or   */
  429.         /*  alias command strings, worst case we report an error        */
  430.         /*--------------------------------------------------------------*/ 
  431.         
  432.         otherwise
  433.             CfgCmd = "";
  434.             CfgCmd = CheckConfig(spare);
  435.         
  436.             if(CfgCmd <> "" ) then do
  437.                 if(argc > 1) then do
  438.                     CfgCmd argv.1
  439.                     end
  440.                 else do
  441.                     CfgCmd
  442.                     end
  443.                 end
  444.             
  445.             else if( CheckAlias(spare) = 1) then do
  446.                 r=lineout(,"Unknown command " spare);
  447.                 end
  448.                 
  449.         end
  450.         
  451. return results;
  452.  
  453. /*------------------------------------------------------*/
  454. /*  Loads configuration file and checks for alternate   */
  455. /*  Potential Arguments:                                */
  456. /*                      -C Alternate Config File        */
  457. /*------------------------------------------------------*/
  458.  
  459. InitConfig:procedure expose Config. CntlShell.
  460.  
  461. argc = Arg(1);
  462. Ops  = Arg(2);
  463. Spare= Arg(2);
  464.  
  465. cfgfile = "DSHELL.CFG"                  /*  Default Name            */
  466. Call Header;                            /*  Show Header             */
  467.  
  468. Config. = "";                           /*  Reset alias and config  */
  469. Config.maxalias = 0;                    /*  Loop control alias      */
  470. Config.maxcfg   = 0;                    /*  Loop control configs    */
  471. Config.maxvol   = 0;                    /*  Loop control volsers    */
  472.  
  473. CntlShell.CurDir = directory();         /*  Get Current Directory   */
  474.  
  475.     /*--------------------------------------------------*/
  476.     /*  The following assumes that we are in a re-init  */
  477.     /*  state as called by user. This is based on the   */
  478.     /*  re-init argument values of 0 and NULL           */
  479.     /*--------------------------------------------------*/
  480.     
  481. if(CntlShell.Home <> "") then do
  482.     if(CntlShell.usedalias = 1 & CntlShell.Cfg <> "") then do
  483.         cfgfile = CntlShell.Cfg;
  484.         end
  485.     else do
  486.         if(CntlShell.Home <> CntlShell.CurDir) then do
  487.             cfgfile = CntlShell.Home'\'CntlShell.Cfg;
  488.             end
  489.         end
  490.     end
  491.  
  492. if( argc > 0 ) then do
  493.     t = 0;
  494.     
  495.     do while(spare <> "")
  496.         parse var spare argv.t spare;
  497.         t = t+1;
  498.         end
  499.         
  500.     l = 0
  501.     
  502.     do while( l < argc )
  503.         if( LEFT(argv.l,2) = "-C") then do
  504.             len = LENGTH(argv.l);
  505.             len = len - 2;
  506.             cfgfile = COPIES(RIGHT(argv.l,len),1)
  507.             r=lineout(,"Alternate configuration file used " cfgfile);
  508.             CntlShell.usedalias = 1;
  509.             end
  510.             
  511.         else if(LEFT(argv.l,2) = "-D") then do
  512.             len = LENGTH(argv.l);
  513.             len = len - 2;
  514.             CntlShell.CurDir = directory(COPIES(RIGHT(argv.l,len),1));
  515.             r=lineout(,"Home directory set to " CntlShell.CurDir);
  516.             end
  517.             
  518.         l = l+1    
  519.         end
  520.     end
  521.     
  522. state=stream(cfgfile,c,"OPEN");                 /*  Open file           */
  523.  
  524. if( state = "READY:" ) then do                  /*  If opened ok        */
  525.  
  526.     if(lines(cfgfile) > 0) then do              /*  And contains data   */
  527.     
  528.         fileline = 0;                           /*  Set filelines       */
  529.                 
  530.         do while lines(cfgfile)                 /*  While more lines    */
  531.         
  532.             fileline = fileline+1;              /*  Have a valid one    */
  533.         
  534.             BigLine = linein(cfgfile);          /*  Get next line in    */
  535.             
  536.  
  537.             BigLine = ClearGarbage(strip(BigLine));
  538.             
  539.             parse var BigLine option delim parm1 parm2
  540.             
  541.             option = translate(option);
  542.             
  543.             /*--------------------------------------*/ 
  544.             /*  If blank or comment ignore process  */
  545.             /*--------------------------------------*/ 
  546.             
  547.             if( option = "" ) then nop;
  548.             
  549.             /*  Assign Alias Options    */
  550.             
  551.             /*--------------------------------------*/
  552.             /*  Assign alias members to array off   */
  553.             /*  the config trunk                    */
  554.             /*--------------------------------------*/             
  555.  
  556.             else if(option = "ALIAS") then do
  557.                 parm1 = CheckComment(strip(parm1));
  558.                 if(parm1 <> "") then do
  559.                     parm2=CheckComment(strip(parm2));
  560.                     if(parm2 <> "")   then do
  561.                         t = Config.maxalias;
  562.                         Config.t = parm1;
  563.                         Config.t.parm1 = parm2;
  564.                         t = t+1
  565.                         Config.maxalias = t;
  566.                         end
  567.                     else do
  568.                         r=lineout(,"Line: "fileline" invalid");
  569.                         end
  570.                     end
  571.                     
  572.                 else do
  573.                     r=lineout(,"Line: "fileline" contains null alias");
  574.                     end
  575.                 end
  576.                 
  577.             /*--------------------------------------*/
  578.             /*  Assign volume lookaside for easy    */
  579.             /*  movement control                    */
  580.             /*--------------------------------------*/
  581.             
  582.             else if( option = "VOL") then do
  583.                 parm1 = CheckComment(strip(parm1));
  584.                 if(parm1 <> "") then do
  585.                     parm2 = CheckComment(strip(parm2));
  586.                     if(parm2 <> "") then do
  587.                         t = Config.maxvol;
  588.                         Config.VOLSERS.t = parm1;
  589.                         Config.VOLSERS.t.0 = parm2;
  590.                         t = t+1;
  591.                         Config.maxvol = t;
  592.                         end
  593.                     else do
  594.                         r=lineout(,"VOL" parm1" set to . at line" fileline);
  595.                         end
  596.                     end
  597.                 else do
  598.                     r=lineout(,"VOL statement line" fileline" contains null");
  599.                     end
  600.                 end
  601.                 
  602.             /*--------------------------------------*/
  603.             /*  Assign Directorys for home and      */
  604.             /*  Help manuals                        */
  605.             /*--------------------------------------*/
  606.             
  607.             else if(option = "HOME") then do
  608.                 parm1 = CheckComment(strip(parm1));
  609.                 if(parm1 <> "") then do
  610.                     CntlShell.Home = parm1;
  611.                     end
  612.                 end                         /*  End Home assigns    */
  613.                 
  614.             else if(option = "HELP") then do
  615.                 parm1=CheckComment(strip(parm1));
  616.                 if(parm1 <> "") then do
  617.                     CntlShell.Help = parm1;
  618.                     end
  619.                 end                         /*  End Help assigns    */
  620.                 
  621.             /*--------------------------------------*/ 
  622.             /*  Assign leaf to step                 */
  623.             /*  Using the function branch members   */
  624.             /*--------------------------------------*/
  625.             
  626.             else do
  627.                 parm1=CheckComment(strip(parm1));
  628.                 if(parm1 <> "") then do
  629.                     t = Config.maxcfg;
  630.                     Config.FUNCTIONS.t = option
  631.                     Config.FUNCTIONS.t.0 = parm1;
  632.                     t = t+1;
  633.                     Config.maxcfg = t;
  634.                     end
  635.                 else do
  636.                     r=lineout(,Config.option "set to . at Fileline :"fileline);
  637.                     end
  638.                 end                         /*  End Config assigns  */
  639.             
  640.             end                             /*  End DoWhile Lines   */
  641.  
  642.         if(CntlShell.Cfg = "") then do
  643.             CntlShell.Cfg = cfgfile; 
  644.             end
  645.             
  646.         state = stream(cfgfile,c,"CLOSE"); 
  647.         
  648.         if(CntlShell.Home = "")  then do
  649.             CntlShell.Home = CntlShell.CurDir;
  650.             end
  651.             
  652.         if(CntlShell.Help = "") then do
  653.             CntlShell.Help = CntlShell.CurDir;
  654.             end
  655.         
  656.         end                                 /*  End if file found   */
  657.         
  658.     else do
  659.         state = stream(cfgfile,c,"CLOSE"); 
  660.         r=lineout(,"Configuration file not found!");
  661.         CntlShell.usedalias = 0;
  662.         'del' cfgfile;
  663.         end                                 /*  End empty file      */
  664.         
  665.     end                                     /*  End open ready      */
  666.     
  667. else do
  668.     r=lineout(,"File open error on" cfgfile "="stream(cfgfile,'D'));
  669.     CntlShell.usedalias = 0;
  670.     end
  671.  
  672. return state;
  673.  
  674. /*------------------------------------------------------*/
  675. /*  Direct and Indirect operating system call           */
  676. /*------------------------------------------------------*/
  677.  
  678. BaseExec: procedure expose Config.
  679. Arg OsCall
  680.  
  681. hit   = 0;
  682.  
  683. parse var OsCall Command Rest
  684.  
  685. if(strip(Rest) = '?') then do
  686.     r=charout(,"Enter option(s) for" Command "call : ");
  687.     parse value linein() with Rest
  688.     end
  689.     
  690. else do
  691.     if ( wordpos("using",Command) | wordpos("USING",Command)) then do
  692.         parse var Rest indirect Rest
  693.         if( strip(Rest) = '?') then do
  694.             r=charout(,"Enter option(s) for" indirect "call : ");
  695.             parse value linein() with Rest
  696.             end
  697.         Command = CheckConfig(strip(indirect));
  698.         hit = 1;
  699.         
  700.         if(Command <> "") then do
  701.             Command Rest
  702.             end
  703.             
  704.         else do
  705.             r=lineout(,"Error processing indirect" indirect Rest);
  706.             end    
  707.         end
  708.     end
  709.        
  710. if(hit = 0) then do 
  711.     Command Rest
  712.     end
  713. return 0;
  714.  
  715. /*------------------------------------------------------*/
  716. /*  Clear unwanted characters from line                 */
  717. /*------------------------------------------------------*/
  718. ClearGarbage: procedure
  719. string = CheckComment(Arg(1));
  720.  
  721.     if(string <> "" & pos('#',string) <> 1) then do
  722.         slen   = length(string);
  723.         loop   = 1;
  724.  
  725.         do while(loop <= slen)
  726.             if( c2d( substr(string,loop,1) ) < 32) then do
  727.                 string = overlay('20'x,string,loop,1);
  728.                 end
  729.             loop = loop+1;
  730.             end
  731.         end
  732.     else do
  733.         string = "";
  734.         end
  735.  
  736. return string;
  737.  
  738. /*------------------------------------------------------*/
  739. /*  Checks string for comment character                 */
  740. /*------------------------------------------------------*/
  741. CheckComment: procedure
  742.  
  743. string = Arg(1);                    /*  Passed string   */
  744.  
  745. if(string <> "") then do            /*  If not null     */
  746.     t=pos("#",string);              /*  Check control   */
  747.     if(t) then do                   /*  If we have it   */
  748.         string = left(string,t);    /*  Copy prefix     */
  749.         end
  750.     end
  751.     
  752. return string;                      /*  Return results  */
  753.  
  754. /*------------------------------------------------------*/
  755. /*  Checks the alias list for a match and operation     */
  756. /*------------------------------------------------------*/
  757. CheckAlias: procedure expose Config.
  758.  
  759. Parse Arg InComing Rest
  760.  
  761. rc=1
  762. t=0;
  763.  
  764. do while(t < Config.maxalias)
  765.     if(COMPARE(Config.t,InComing) = 0) then do
  766.         rc = 0;
  767.         PARSE UPPER VAR Config.t.InComing command argument
  768.         if(command = 'EXEC') then do
  769.             rc=BaseExec(argument);
  770.             t = Config.maxalias;
  771.             end
  772.         else do
  773.             r=lineout(,"Syntax error in alias line "Config.t.InComing);
  774.             end
  775.         end
  776.     t = t+1
  777.     end
  778.  
  779. return rc;
  780.  
  781. /*------------------------------------------------------*/
  782. /*  Checks the configuration function list for the      */ 
  783. /*  passed parameter and returns match string if found  */
  784. /*------------------------------------------------------*/ 
  785. CheckConfig: procedure  expose Config.
  786.  
  787. Parse Upper Arg InComing Rest
  788.  
  789. i = 0;
  790. match = "";
  791.  
  792. do while ( i < Config.maxcfg )
  793.     if(InComing = Config.FUNCTIONS.i) then do
  794.         match = Config.FUNCTIONS.i.0;
  795.         i = Config.maxcfg;        
  796.         end
  797.     i = i+1;
  798.     end
  799.  
  800. return match;
  801.  
  802. /*------------------------------------------------------*/ 
  803. /*  Checks the volser list for a match with the passed  */
  804. /*  parameter and returns matching string if found      */
  805. /*------------------------------------------------------*/
  806. CheckVolumes: procedure expose Config.
  807.  
  808. InComing = Arg(1);
  809.  
  810. match = "";
  811. i = 0;
  812.     
  813. do while( i < Config.maxvol )
  814.     if( InComing = Config.VOLSERS.i) then do
  815.         match = Config.VOLSERS.i.0;
  816.         i = Config.maxvol;
  817.         end
  818.     i = i+1;
  819.     end
  820.     
  821. return match;
  822.  
  823. /*
  824. $Log:    devshell.cmd $
  825. Revision 1.10  91/12/22  21:23:36  FJC
  826. Cleaned up configuration parser
  827. Added Vset Aset and Cset commands
  828. Added Info command
  829. Fixed problem with tabs in config file
  830. Removed CDD ( go does same thing only better )
  831. Extended Help File Manual
  832.  
  833. Revision 1.9  91/12/08  18:26:48  FJC
  834. Included command line parsing in init routine
  835.  
  836. Revision 1.8  91/12/08  18:18:34  FJC
  837. Corrected command line argument processing on startup
  838.  
  839. Revision 1.7  91/12/08  12:55:53  FJC
  840. Tested indirect rexx call as alias command
  841.  
  842. */
  843.