home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / tvconfig.zip / tvconfig.cmd < prev    next >
OS/2 REXX Batch file  |  1998-02-24  |  3KB  |  97 lines

  1. /* TVFS.CONF / TVFS Configuration Utility / release 2C    */
  2. /* written by Byron Q. Desnoyers Winmill                  */
  3. /*                                                        */
  4. /* Revision History:                                      */
  5. /* 16-Sep-97 : release 1                                  */
  6. /*     original release                                   */
  7. /* 26-Sep-97 : release 2                                  */
  8. /*     numerous parsing fixes                             */
  9. /*     consistent error messages                          */
  10. /*     cleaned up code                                    */
  11. /*     fixed comment bugs                                 */
  12. /* 24-Feb-98 : release 2C
  13.  *    Converted code to standard REXX.
  14.  *    ! Script no longer runs TVCTL.
  15.  * UPCOMING! : release 3
  16.  *    Checks environment for TVFS.CONF.
  17.  *    Added TVLN linking utility.
  18.  */
  19.  
  20. /* todo: make constants more accessable */
  21.  
  22. '@ ECHO OFF'
  23.  
  24. /* Define global constants.           */
  25. TITLE='[tvfs.conf]';
  26. COMMENT='#';
  27. DISPLAY='!';
  28. DIVIDER=',';
  29.  
  30.  
  31. /* Parse command line.                */
  32. parse arg tvfsconf tvdrives;
  33.  
  34. call Initialize;
  35. call Mount tvdrives;
  36. call Link tvfsconf;
  37. call Terminate 0;
  38.  
  39. Initialize : procedure expose TITLE
  40.     rc = RxFuncAdd('TvLoadFuncs','TVRX','TvLoadFuncs');
  41.     if ( rc <> 0 ) then do
  42.         say TITLE '| Error calling RxFuncAdd()';
  43.         call Terminate 1;
  44.     end;                            /* if : rc */
  45.  
  46.     rc = TvLoadFuncs();
  47.     if ( rc <> 0 ) then do
  48.         say TITLE '| Error calling TvLoadFuncs()';
  49.         call Terminate 2;
  50.     end;                            /* if : rc */
  51. return 0;                            /* procedure initialize */
  52.  
  53. Mount : procedure expose TITLE
  54.     arg tvdrives;
  55.  
  56.     do while ( Length(tvdrives) > 0 )
  57.         parse var tvdrives this_drive (DIVIDER) tvdrives;
  58.         rc = TvMount(this_drive':');
  59.         if ( rc <> 0 ) then say TITLE '| Warning, could not mount 'this_drive':'
  60.     end;                            /* while : tv_drives */
  61. return 0;                            /* procedure : Mount */
  62.  
  63. Link : procedure expose TITLE COMMENT DISPLAY
  64.     arg tvfsconf;
  65.  
  66.     call Stream tvfsconf, 'c', 'open read';
  67.     do while ( Lines(tvfsconf) \= 0 )
  68.         buffer = LineIn(tvfsconf);
  69.  
  70.         if ( Length(buffer) > 0 ) then do
  71.             parse var buffer command 2 string;
  72.             select
  73.                 when ( command = COMMENT ) then
  74.                     nop;
  75.                 when ( command = DISPLAY ) then
  76.                     say title string;
  77.                 otherwise
  78.                     parse var buffer parameters source destination;
  79.                     if ( Length(source) = 0 ) | ( Length(destination) = 0 ) then
  80.                         say TITLE '| Warning, could not link' buffer;
  81.                     else do
  82.                         rc = TvLink(parameters source destination);
  83.                         if ( rc <> 0 ) then say TITLE '| Warning, error' rc 'linking' buffer;
  84.                     end;            /* if : source, destination */
  85.             end;                    /* select */
  86.         end;                        /* if : buffer */
  87.     end;                            /* while : tvfsconf */
  88.     call Stream tvfsconf, 'c', 'close';
  89. return 0;                            /* procedure : Link */
  90.  
  91. Terminate : procedure
  92.     arg exitcode;
  93.     call TvDropFuncs;
  94.     exit(exitcode);
  95. return 0;                            /* procedure : Terminate */
  96.  
  97.