SUBDIR.PAS 2.4 KB

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