home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / IOFUNC.ZIP / TOPTION.TST < prev    next >
Encoding:
Text File  |  1986-04-12  |  2.9 KB  |  74 lines

  1. {           ╔═══╦══════════════════════════════════════════════╦═══╗
  2.             ║   ║         Pascal Library by Scott Wade         ║   ║
  3.             ║   ║           715 FM 1959      Apt 310           ║   ║
  4.             ║   ║           Houston, TX 77034                  ║   ║
  5.      ┌──────╨───╨──────────────────────────────────────────────╨───╨──────┐
  6.      │  This  group of routines is contributed to public domain,  and no  │
  7.      │  one can possibly get any commercial value out of them since they  │
  8.      │  must be used in other programs. I require that if these are used  │
  9.      │  as is in  any  program,  that this banner remain with the source  │
  10.      │  code of the program.  I would appreciate any comments or sugges-  │
  11.      │  tions on improvements, & am curious to hear how these are used.   │
  12.      │  You can leave a message for me on these BBS's:                    │
  13.      │          Ziggy's  821-1391         ScoreBoard  583-7848            │
  14.      │          TBL-COMM 661-9040         Test-Mode   660-9252            │
  15.      └────────────────────────────────────────────────────────────────────┘
  16.  
  17.  TOPTION.TST v1.0   Command option parser.
  18.  v1.0:  4/11/86 : Given a buffer, this will extract a one-letter option that
  19.         is preceded by /. For example:
  20.         JOBRUN /f filename.ext
  21.         will return 70, the ascii equivalent of 'F', and the buffer will be
  22.         'filename.ext' NOTE: it converts to uppercase!
  23. }
  24.  
  25. Type
  26.    Buffer       =  string[ 255 ];
  27.    LongWord     =  string[  20 ];
  28.    Word         =  string[  10 ];
  29.    LongWordList =  array[ 1..16 ] of LongWord ;
  30.    WordList     =  array[ 1..16 ] of Word ;
  31. { NOTE: all of the above are global types for INC and LIB files. }
  32. var
  33.    Loop, AscOpt  : Integer ;
  34.    TestBuf : Buffer  ;
  35.  
  36. {$I tOption.LIB}
  37.  
  38. Function SelectBuffer( var SetOption : Integer ): Buffer;
  39. begin
  40.    Case SetOption of
  41.       1    :   SelectBuffer := ''  ;
  42.       2    :   SelectBuffer := '/' ;
  43.       3    :   SelectBuffer := '/A';
  44.       4    :   SelectBuffer := '/f filejunk'   ;
  45.       5    :   SelectBuffer := 'filejunk /f'   ;
  46.       6    :   SelectBuffer := '/a junkfile /f';
  47.       7    :   SelectBuffer := 'No Option Here!';
  48.    end{ Case };
  49. end{ F SelectBuffer };
  50.  
  51. begin
  52.    { Try it with TestBuf set to the following:
  53.      || Null                 |/|  slash only     |/A| option only, uppercase
  54.      |/f filejunk|           |junkfile /f|       |/a junkfile /f|
  55.    In the case of multiple options, will return the first encountered.
  56.    }
  57.    GoToXY(1,10);
  58.    writeln('Test of tOption.LIB v1.0 ');
  59.    writeln;
  60.    For Loop := 1 to 7 do begin
  61.       TestBuf := SelectBuffer( Loop );
  62.       AscOpt  := 0;
  63.       writeln;
  64.       write('Buffer In: |',TestBuf,'|  ');
  65.       tOption( TestBuf, AscOpt );
  66.       writeln('Buffer Out: |',TestBuf,'|   Option:',
  67.               chr( AscOpt ), AscOpt:5 );
  68.    end{ Loop };
  69. end{ tOption.TST }.
  70.  
  71.  
  72.  
  73.  
  74.