home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / dskutl / lan.arc / LANMKDIR.PAS < prev    next >
Pascal/Delphi Source File  |  1988-06-18  |  6KB  |  183 lines

  1. program makedir(input,output);
  2.  
  3.    {
  4.  
  5.    Program reads datafile of filenames, and writes as output the
  6.    batch file 'x1.bat' for making directories.
  7.    These directories themselves are piped to a data file,
  8.    named 'x1.dat'.
  9.  
  10.    }
  11.  
  12. const
  13.   version = '1.00';
  14.   progname = 'LANMKDIR ';
  15.   ctlh = #08;
  16.   cret = #13;
  17.   linf = #10;
  18.   ctrlz= #26;
  19.   diagnostic = false;             {enables, disables diagnostic messages}
  20.   echoline= 'echo -------------------------------- >>x1.dat ';
  21.  
  22. type
  23.   string2=string[2];
  24.   string3=string[3];
  25.  
  26. label
  27.   notag;
  28.  
  29.  
  30. var
  31.   infiler: file of char;
  32.   outfiler:text;
  33.   ch:char;
  34.   drive:string[1];
  35.   subdir:string[6];
  36.   text_string,
  37.   text_string1,
  38.   text_string2:string[80];
  39.   time_string:string[80];
  40.   kounter:integer;
  41.   yr,mo,da,hr,mn:string[2];
  42.   fname:string[12];
  43.   floppydrive,harddrive:string[2];
  44.   input_file:string[12];
  45.   reading:boolean;
  46.   i,command_length:integer;
  47.   command_temp: string[128];
  48.   command_line: string[128] absolute cseg:$0080;
  49.  
  50. procedure boxlike;
  51.  
  52. begin
  53. clrscr;
  54. gotoxy(0,0);
  55. writeln ('┌─────────────────────────────────────────────────────────────────────────────┐');
  56. writeln ('│                                                                             │');
  57. writeln ('│                                                                             │');
  58. writeln ('│                                                                             │');
  59. writeln ('│                                                                             │');
  60. writeln ('│                                                                             │');
  61. writeln ('│                                                                             │');
  62. writeln ('│                                                                             │');
  63. writeln ('│                                                                             │');
  64. writeln ('│                                                                             │');
  65. writeln ('│                                                                             │');
  66. writeln ('│                                                                             │');
  67. writeln ('└─────────────────────────────────────────────────────────────────────────────┘');
  68. gotoxy(29,3);
  69. write ('F L O P P Y  -  L A N');
  70. gotoxy(52,4);
  71. write ('System (C) by:');
  72. gotoxy(52,6);
  73. write ('Leonard P. Levine');
  74. gotoxy(52,7);
  75. write ('3942 N. Oakland Ave. #241');
  76. gotoxy(52,8);
  77. write ('Shorewood, WI 53211');
  78. gotoxy(52,9);
  79. write ('(414) 962-4719');
  80. gotoxy(52,10);
  81. write ('len@evax.milw.wisc.edu');
  82. gotoxy(3,12);
  83. write ('Program:',progname);
  84. gotoxy(52,12);
  85. write('Version: ',version);
  86. gotoxy(7,9);
  87. write ('Floppy Drive:   ',floppydrive);
  88. gotoxy(7,10);
  89. write ('  Hard Drive:   ',harddrive);
  90. gotoxy(7,6);
  91. write ('  Input File:   ',input_file);
  92. gotoxy(3,8);
  93. write(' ');
  94. end;
  95.  
  96. procedure lastbox;
  97. begin
  98. gotoxy(1,13);
  99. writeln ('├─────────────────────────────────────────────────────────────────────────────┤');
  100. writeln ('│    Messages like: "File not found" and "Invalid Directory" are normal only  │');
  101. writeln ('│    after new files are added to the lan datafile.                           │');
  102. writeln ('└─────────────────────────────────────────────────────────────────────────────┘');
  103. end;
  104.  
  105. {main Program}
  106. begin
  107. command_temp := command_line;
  108. command_length := length(command_temp);
  109. floppydrive:= 'A:';
  110. harddrive := 'C:';
  111. if command_length <> 0 then
  112.     begin
  113.     while copy(command_temp,1,1) = ' ' do
  114.      command_temp := copy(command_temp,2,44)+' '; {clear out blanks}
  115.     floppydrive  := copy(command_temp,1,1) + ':';
  116.     harddrive  := copy(command_temp,2,1) + ':';
  117.     end;
  118. input_file := 'LAN.FIL';
  119. if command_length > 5 then input_file := copy(command_temp,4,12);
  120. boxlike;
  121. kounter := 1;
  122. write ('Files Supported: ');
  123. if diagnostic then writeln('Inputting from file "',input_file,'".');
  124. assign (infiler,input_file);
  125. assign (outfiler,'x1.bat');
  126. {$I-}
  127. Reset(infiler);
  128. if ioresult <> 0 then
  129.   begin
  130.   gotoxy(1,15);
  131.   writeln('File ',input_file,' does not exist');
  132.   halt
  133.   end;
  134. {$I+}
  135. reset (infiler);
  136. rewrite(outfiler);
  137. if diagnostic then
  138.   begin
  139.   writeln;
  140.   writeln ('Output to file "X1.BAT":');
  141.   writeln ('echo -------------------------------- >x1.dat ');
  142.   end;
  143. if not diagnostic then
  144.   writeln(outfiler,'@echo off');
  145. writeln(outfiler,'echo --System Messages, if any-----');
  146. writeln(outfiler,'echo -------------------------------- >x1.dat ');
  147. while not eof(infiler) do
  148.   begin                        {endfiler}
  149.   {    Characters:1234567890    }
  150.   text_string := 'file:     ';
  151.   reading := true;
  152.   while reading do
  153.     begin                      {reading}
  154.     read(infiler,ch);
  155.     case ch of
  156.       ctrlz: reading := false;
  157.       cret: reading := false;
  158.       linf: reading := false;
  159.       else begin
  160.            text_string := text_string + ch;
  161.            end;
  162.       end;
  163.     end;                       {reading}
  164.   if text_string <> 'file:     ' then
  165.     begin                       {goodline}
  166.     text_string1 := 'dir ' + floppydrive + copy(text_string,11,60) + ' >>x1.dat';
  167.     text_string2 := 'dir ' + harddrive + copy(text_string,11,60) + ' >>x1.dat';
  168.     if diagnostic then writeln(text_string1);
  169.     if diagnostic then writeln(echoline);
  170.     if diagnostic then writeln(text_string2);
  171.     if diagnostic then writeln(echoline);
  172.     write (kounter:4,ctlh,ctlh,ctlh,ctlh);
  173.     kounter := kounter + 1;
  174.     writeln(outfiler,text_string1);
  175.     writeln(outfiler,echoline);
  176.     writeln(outfiler,text_string2);
  177.     writeln(outfiler,echoline);
  178.     end;
  179.   end;                             {endfiler}
  180. close(outfiler);
  181. lastbox;
  182. end.
  183.