home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l039 / 1.img / EXAMPLEX / DIRECT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-03-18  |  2.4 KB  |  81 lines

  1. Program DirectoryExamples;
  2.  
  3. {
  4.       DIRECTORY PROCEDURES DEMONSTRATION PROGRAM  Version 1.00A
  5.  
  6.   This program demonstrates the use of TURBO 3.0 directory procedures.
  7.  
  8.   PSEUDO CODE
  9.   1.  Get the current drive and directory
  10.   2.  Repeat
  11.         Execute the selected TURBO directory procedure
  12.       until the user types "Q" or "0"
  13.  
  14.  INSTRUCTIONS
  15.  1.  Compile this program using the TURBO.COM compiler.
  16.  2.  Manipulate the directory commands by selecting the menu options.
  17.  3.  Type "Q" or "0" to exit the program.
  18. }
  19.  
  20. Var
  21.   Path: String[64];
  22.   Ch: Char;
  23.  
  24. Begin
  25.   ch := '1';   { initialize loop variable }
  26.   Repeat
  27.     if Upcase(ch) IN ['1', 'M', '2', 'R', '3', 'C', '0', 'Q'] then
  28.       begin
  29.          ClrScr;
  30.          GetDir(0,Path); { Get the current directory of the current drive.
  31.                            Note that 0 for the first variable means the current
  32.                            drive, not A:.  1 means A: and so on.   This is contrary
  33.                            to the manual }
  34.          WriteLn('Current directory is ',Path);
  35.          Writeln;
  36.          WriteLn('Choose option: ');
  37.          WriteLn('  1: Make a directory');
  38.          WriteLn('  2: Remove a directory');
  39.          WriteLn('  3: Change the current directory');
  40.          WriteLn('  0: Quit');
  41.          Writeln;
  42.          Write('Option: ');
  43.          Read(Kbd,Ch);
  44.  
  45.          {$I-}
  46.          Case Upcase(Ch) Of
  47.            '1','M': Begin
  48.                       WriteLn('Make');
  49.                       Write('Make what directory? ');
  50.                       Readln(path);
  51.                       MkDir(Path);
  52.                     End;
  53.            '2','R': Begin
  54.                       WriteLn('Remove');
  55.                       Write('Remove what directory? ');
  56.                       Readln(path);
  57.                       RmDir(Path);
  58.                     End;
  59.            '3','C': Begin
  60.                       WriteLn('Change');
  61.                       Writeln;
  62.                       Write('Change to what directory? ');
  63.                       Readln(path);
  64.                       ChDir(Path); 
  65.                     End;
  66.            '0','Q': WriteLn('Quit');
  67.            Else
  68.           End; { case }
  69.  
  70.          {$I+}
  71.          If IOResult<>0 Then
  72.             begin
  73.               Write('*** Error: ', path);
  74.               delay(3000);
  75.             end;
  76.        end { if }
  77.      else
  78.        read(kbd, ch)
  79.     Until Upcase(Ch) In ['0','Q', #27];
  80. End.
  81.