home *** CD-ROM | disk | FTP | other *** search
- program vl_test;
- {
- Test shell for VL, a volume labeling unit for Turbo Pascal 4.0
-
- Assumes that the user wants to add or modify the label on drive A:.
- If no command line parameters are input, it prompts for the required input.
- Other drives may be specified on the command line:
-
- vl_test b: label_001
-
- Note: the drive parameter MUST be present and be the first parameter if
- both parameters are input. When present, the new label is always the
- second parameter. Because of the manner in which command line parameters
- are handled, labels specified on the command line may NOT
- contain leading or embedded spaces. Labels input via prompt may contain
- spaces as long as the label does not begin with them.
-
- The author places no restrictions on code usage and accepts no responsibility
- for performance or problems arising from usage.
- Stuart Johnson, Compuserve 71331,1716
- }
- uses vl;
-
- var drive_str,
- command,
- old_label,
- str : string;
- stat,
- disk : byte;
-
-
-
- {==================================================}
- function ds_to_dn(in_str : string; var num : byte): boolean;
- {
- function to change drive string to drive number.
- Input: string
- Output: number 1..26 = true
- other = false
- }
- var ch : char;
-
- begin
- if (length(in_str) = 2) and (pos(':',in_str) = 2) then
- begin
- ch := in_str[1];
- if ch in ['A'..'Z'] then num := ord(ch) - ord('A') + 1;
- if ch in ['a'..'z'] then num := ord(ch) - ord('a') + 1;
- end;
- if (num > 0) and (num < 27) then ds_to_dn := true else
- begin
- ds_to_dn := false;
- num := 0;
- end;
- end;
-
-
-
- {=====================================================}
- procedure getparams(var disk : byte; var str : string);
- {
- Read command line for input paramters
- 1) drive name a..z and optionally..
- 2) new label
- }
- var stat : boolean;
-
- begin
- stat := ds_to_dn(paramstr(1),disk);
- if paramcount = 2 then str := copy(paramstr(2),1,length(paramstr(2)));
- end;
-
-
- begin
- disk := 0;
- str := '';
- if paramcount > 0 then getparams(disk,str);
-
- if disk = 0 then { if not passed (successfully) on command line }
- repeat
- write('Enter drive to modify [2 chars, default = A:]: ');
- readln(drive_str);
- if length(drive_str) = 0 then drive_str := 'A:';
- until ds_to_dn(drive_str,disk);
- stat := get_volume_label(disk,old_label);
- case stat of
- vl_success : writeln('Old label: ',old_label);
- vl_nolabel : writeln('Volume does not have a label');
- else writeln('Unknown error: ',stat);
- end;
-
- command := 'M';
- if length(str) = 0 then { if not passed on command line }
- begin { then prompt }
- write('Add/Modify or Delete label [M,D, default=M]: ');
- readln(command);
- end;
-
-
- if not (command[1] in ['D','d']) then
- begin
-
- if length(str) = 0 then { if not passed on command line }
- begin
- write('Enter new label [1..11 chars]: ');
- readln(str);
- end;
-
- stat := put_volume_label(disk,str);
- case stat of
- vl_success : writeln('Successfully added/modified label');
- vl_disk : writeln('Invalid drive number: ',disk);
- vl_label : writeln('Invalid volume label: ',str);
- vl_create : writeln('Volume label creation failed');
- vl_rename : writeln('Volume label rename failed');
- else writeln('Unknown failure: ',stat);
- end; { case }
- end { command = A or a }
- else { command explicitly D or d }
- begin
- stat := delete_volume_label(disk);
- case stat of
- vl_success : writeln('Successfully deleted volume label');
- vl_delete : writeln('Volume label deletion failed');
- vl_nolabel : writeln('Volume does not have a label');
- else writeln('Unknown failure: ',stat);
- end; { case }
- end;
- end.