home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / VL.ZIP / VL_TEST.PAS next >
Encoding:
Pascal/Delphi Source File  |  1988-02-28  |  3.7 KB  |  129 lines

  1. program vl_test;
  2. {
  3.  Test shell for VL, a volume labeling unit for Turbo Pascal 4.0
  4.  
  5.  Assumes that the user wants to add or modify the label on drive A:.
  6.  If no command line parameters are input, it prompts for the required input.
  7.  Other drives may be specified on the command line:
  8.  
  9. vl_test b: label_001
  10.  
  11.  Note: the drive parameter MUST be present and be the first parameter if
  12.        both parameters are input. When present, the new label is always the
  13.        second parameter. Because of the manner in which command line parameters
  14.        are handled, labels specified on the command line may NOT
  15.        contain leading or embedded spaces. Labels input via prompt may contain
  16.        spaces as long as the label does not begin with them.
  17.  
  18.  The author places no restrictions on code usage and accepts no responsibility
  19.  for performance or problems arising from usage.
  20.  Stuart Johnson, Compuserve 71331,1716
  21. }
  22. uses vl;
  23.  
  24. var     drive_str,
  25.         command,
  26.         old_label,
  27.         str  : string;
  28.         stat,
  29.         disk : byte;
  30.  
  31.  
  32.  
  33. {==================================================}
  34. function ds_to_dn(in_str : string; var num : byte): boolean;
  35. {
  36. function to change drive string to drive number.
  37. Input:  string
  38. Output: number 1..26 = true
  39.         other        = false
  40. }
  41. var  ch : char;
  42.  
  43. begin
  44.  if (length(in_str) = 2) and (pos(':',in_str) = 2) then
  45.  begin
  46.   ch := in_str[1];
  47.   if ch in ['A'..'Z'] then num := ord(ch) - ord('A') + 1;
  48.   if ch in ['a'..'z'] then num := ord(ch) - ord('a') + 1;
  49.  end;
  50.  if (num > 0) and (num < 27) then ds_to_dn := true else
  51.  begin
  52.   ds_to_dn := false;
  53.   num := 0;
  54.  end;
  55. end;
  56.  
  57.  
  58.  
  59. {=====================================================}
  60. procedure getparams(var disk : byte; var str : string);
  61. {
  62.  Read command line for input paramters
  63.  1) drive name a..z        and optionally..
  64.  2) new label
  65. }
  66. var  stat : boolean;
  67.  
  68. begin
  69.  stat  := ds_to_dn(paramstr(1),disk);
  70.  if paramcount = 2 then str := copy(paramstr(2),1,length(paramstr(2)));
  71. end;
  72.  
  73.  
  74. begin
  75.  disk := 0;
  76.  str := '';
  77.  if paramcount > 0 then getparams(disk,str);
  78.  
  79.  if disk = 0 then            { if not passed (successfully) on command line }
  80.  repeat
  81.   write('Enter drive to modify [2 chars, default = A:]: ');
  82.   readln(drive_str);
  83.   if length(drive_str) = 0 then drive_str := 'A:';
  84.   until ds_to_dn(drive_str,disk);
  85.  stat := get_volume_label(disk,old_label);
  86.  case stat of
  87.   vl_success : writeln('Old label: ',old_label);
  88.   vl_nolabel : writeln('Volume does not have a label');
  89.   else writeln('Unknown error: ',stat);
  90.  end;
  91.  
  92.  command := 'M';
  93.  if length(str) = 0 then     { if not passed on command line }
  94.  begin                       { then prompt }
  95.   write('Add/Modify or Delete label [M,D, default=M]: ');
  96.   readln(command);
  97.  end;
  98.  
  99.  
  100.  if not (command[1] in ['D','d']) then
  101.  begin
  102.  
  103.   if length(str) = 0 then    { if not passed on command line }
  104.   begin
  105.    write('Enter new label [1..11 chars]: ');
  106.    readln(str);
  107.   end;
  108.  
  109.   stat := put_volume_label(disk,str);
  110.   case stat of
  111.    vl_success : writeln('Successfully added/modified label');
  112.    vl_disk    : writeln('Invalid drive number: ',disk);
  113.    vl_label   : writeln('Invalid volume label: ',str);
  114.    vl_create  : writeln('Volume label creation failed');
  115.    vl_rename  : writeln('Volume label rename failed');
  116.    else writeln('Unknown failure: ',stat);
  117.   end; { case }
  118.  end  { command = A or a }
  119.  else { command explicitly D or d }
  120.  begin
  121.   stat := delete_volume_label(disk);
  122.   case stat of
  123.    vl_success   : writeln('Successfully deleted volume label');
  124.    vl_delete    : writeln('Volume label deletion failed');
  125.    vl_nolabel   : writeln('Volume does not have a label');
  126.    else writeln('Unknown failure: ',stat);
  127.   end; { case }
  128.  end;
  129. end.