home *** CD-ROM | disk | FTP | other *** search
- {---------READAXSD-----------Read comments from AUTODEX or SDIR files-------}
- {---------------Replace the procedure Update_Disk with this file-----------}
-
- type commentype_np=array[1..Max_Records] of Record
- thecomment:memo_type;
- thefile:fname_type;
- end;
- commentype=^commentype_np;
-
- function DIDFileName:fname_type;
- {
- This program returns the name of the .DID file on the default disk, or
- the null string if there is no .DID file
- }
- type
- Char12arr = array [ 1..12 ] of Char;
- String20 = string[ 20 ];
- RegRec =
- record
- AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags : Integer;
- end;
-
- var NumFiles : integer;
- Regs : RegRec;
- DTA : array [ 1..43 ] of Byte;
- Mask : Char12arr;
- NamR : String20;
- Error, I : Integer;
-
- begin
- FillChar(DTA,SizeOf(DTA),0); { Initialize the DTA buffer }
- FillChar(Mask,SizeOf(Mask),0); { Initialize the mask }
- FillChar(NamR,SizeOf(NamR),0); { Initialize the file name }
- NumFiles := 0;
- Regs.AX := $1A00; { Function used to set the DTA }
- Regs.DS := Seg(DTA); { store the parameter segment in DS }
- Regs.DX := Ofs(DTA); { " " " offset in DX }
- MSDos(Regs); { Set DTA location }
- Error := 0;
- Mask := '????????.DID'; { Use global search }
- Regs.AX := $4E00; { Get first directory entry }
- Regs.DS := Seg(Mask); { Point to the file Mask }
- Regs.DX := Ofs(Mask);
- Regs.CX := 22; { Store the option }
- MSDos(Regs); { Execute MSDos call }
- Error := Regs.AX and $FF; { Get Error return }
- I := 1; { initialize 'I' to the first element }
- if (Error = 0) then
- repeat
- NamR[I] := Chr(Mem[Seg(DTA):Ofs(DTA)+29+I]);
- I := I + 1;
- until not (NamR[I-1] in [' '..'~']) or (I>20);
-
- NamR[0] := Chr(I-1); { set string length because assigning }
- { by element does not set length }
- DIDFileName := NamR;
-
- end; { procedure DirList }
-
-
- function UpC(name:fname_type):fname_type;
-
- var temp:fname_type;
- I:integer;
-
- begin
- for i := 0 to length(name) do
- temp[i] := UpCase(name[i]);
- UpC := temp;
- end; {then}
-
-
- function CompareFileNames(name1,name2:fname_type):boolean;
-
- begin
- While pos('.',name1)>0 do delete(name1,pos('.',name1),1);
- While pos('.',name2)>0 do delete(name2,pos('.',name2),1);
- While pos(' ',name1)>0 do delete(name1,pos(' ',name1),1);
- While pos(' ',name2)>0 do delete(name2,pos(' ',name2),1);
- CompareFileNames := UpC(name1)<>UpC(name2);
- end; {function}
-
- procedure GetAxComments(var comments:commentype;var NumberOfComments:integer);
-
- type strings=array[1..47] of char;
-
- var tempstr:string[47];
- i:integer;
- garbage:char;
- infile:text;
- temporary:strings;
-
- begin
- tempstr := DIDFileName+'D';
- assign(infile,tempstr);
- reset(infile);
- readln(infile);readln(infile);
- NumberOfComments := 0;
- While not eof(infile) do
- begin
- NumberOfComments := NumberOfComments + 1;
- for i := 1 to 13 do read(infile,garbage);
- for i := 1 to 13 do read(infile,temporary[i]);
- tempstr := temporary;
- Delete(tempstr,pos('.',tempstr),1);
- Comments^[NumberOfComments].TheFile := copy(Tempstr,1,11);
- for i := 1 to 7 do read(infile,garbage);
- for i := 1 to 47 do temporary[i] := ' ';
- i := 1;
- While not eoln(infile) do
- begin read(infile,temporary[i]); i := i+1; end; {while}
- tempstr := temporary;
- Comments^[NumberOfComments].TheComment := copy(Tempstr,1,33);
- readln(infile);
- end; {while}
- close(infile);
- end; {procedure}
-
- Procedure GetSdComments(var comments:commentype;var NumberOfComments:integer);
-
- type strings=array[1..47] of char;
-
- var tempstr:string[47];
- i:integer;
- garbage:char;
- infile:text;
- temporary:strings;
-
- begin
- assign(infile,'SDIR.$$$');
- reset(infile);
- NumberOfComments := 0;
- while not eof(infile) do
- begin
- NumberOfComments := NumberOfComments + 1;
- for i := 1 to 47 do temporary[i] := ' ';
- for i := 1 to 12 do read(infile,temporary[i]);
- tempstr := temporary;
- Delete(tempstr,pos('.',tempstr),1);
- comments^[NumberOfComments].TheFile := Copy(tempstr,1,11);
- for i := 1 to 27 do read(infile,garbage);
- for i := 1 to 47 do temporary[i] := ' ';
- for i := 1 to 41 do read(infile,temporary[i]);
- tempstr := temporary;
- comments^[NumberOfComments].TheComment := Copy(tempstr,1,33);
- end; {while}
- close(infile);
- end; {procedure}
-
-
- procedure ReadAxSd(ax:boolean);
-
- label EndProc;
-
- var comments:commentype;
- tempint17:integer;
- Numberofcomments:integer;
-
- begin
- changed := true;
- New(comments);
- If ax then GetAxComments(comments,Numberofcomments) else GetSdComments(comments,numberofcomments);
- found := false;
- writeln;
- get_vol;
- if volume <> '' then
- begin
- writeln;
- for x := 1 to vol_num do
- begin
- If vol_array[x]=volume then
- begin
- found := true;
- t1 := x;
- t4 := x;
- end;
- end;
- If not Found then
- begin
- t1 := 0;
- t4 := vol_num;
- cat_num := cat_num + 1;
- vol_array[vol_num] := volume;
- cat_array[cat_num].vol_record := -1;
- cat_array[cat_num].fil := volume;
- cat_array[cat_num].memo := 'Volume Label';
- end; {then}
- writeln;
- vol_min := 0;
- vol_max := 0;
- writeln ('Reading catalog.. One moment...');
- t2 := 0; { count files found on disk }
- for x := 1 to cat_num do
- if (cat_array[x].vol_record = t1) and (vol_min = 0) then
- vol_min := x
- else
- if (vol_min <> 0 ) and (vol_max = 0) and (cat_array[x].vol_record <> t1) then
- vol_max := x - 1 ;
- If not Found then vol_min := cat_num+1;
- if vol_max = 0 then vol_max := cat_num;
- msdos11(3);
- if (r.ax and 255) = 0 then
- begin
- while (r.ax and 255) = 0 do
- begin {q1}
- t2 := t2 + 1;
- temp := '';
- for x := 8 to 18 do
- temp := temp + chr(mem[seg(dta^):ofs(dta^)+x]);
- temp_array[t2].fil := temp;
- temp_array[t2].sizelo[1] := chr(mem[seg(dta^):ofs(dta^)+36]);
- temp_array[t2].sizelo[2] := chr(mem[seg(dta^):ofs(dta^)+37]);
- temp_array[t2].sizehi[1] := chr(mem[seg(dta^):ofs(dta^)+38]);
- temp_array[t2].sizehi[2] := chr(mem[seg(dta^):ofs(dta^)+39]);
- temp_array[t2].time[1] := chr(mem[seg(dta^):ofs(dta^)+30]);
- temp_array[t2].time[2] := chr(mem[seg(dta^):ofs(dta^)+31]);
- temp_array[t2].date[1] := chr(mem[seg(dta^):ofs(dta^)+32]);
- temp_array[t2].date[2] := chr(mem[seg(dta^):ofs(dta^)+33]);
- {-- now find old entry if any --}
- found := false;
- for x := vol_min to vol_max do
- begin
- if cat_array[x].fil = temp then
- begin
- found := true;
- t3 := x;
- end;
- end;
- tempint17 := 1;
- while (tempint17<Numberofcomments)
- and CompareFileNames(temp_array[t2].fil,comments^[tempint17].thefile)
- do tempint17 := tempint17+1;
- If CompareFileNames(temp_array[t2].fil,comments^[tempint17].thefile)
- then temp_array[t2].memo := ''
- else temp_array[t2].memo := comments^[tempint17].thecomment;
- msdos12;
- end
- end;
- If t1=0 then
- begin
- for x := 1 to t2 do begin
- cat_array[x+cat_num].vol_record := t4;
- cat_array[x+cat_num].fil := temp_array[x].fil;
- cat_array[x+cat_num].sizelo := temp_array[x].sizelo;
- cat_array[x+cat_num].sizehi := temp_array[x].sizehi;
- cat_array[x+cat_num].time := temp_array[x].time;
- cat_array[x+cat_num].date := temp_array[x].date;
- cat_array[x+cat_num].memo := temp_array[x].memo;
- end; {for}
- cat_num := cat_num + t2;
- goto EndProc;
- end; {then}
- t1 := vol_max - vol_min + 1;
- if t1 < t2 then
- begin
- {check to see if we will overrun the array}
- if (cat_num + (t2 - t1)) > max_records then
- begin
- writeln ('Maximum of ',max_records,' files exceeded by ',cat_num + t2 - t1 - max_records,'.');
- writeln ('Truncating to ',max_records);
- end;
- {move the file up t2 - t1 records}
- for x := (cat_num + t2 - t1) downto (vol_max + t2-t1 + 1) do
- cat_array[x] := cat_array[x - t2+t1];
- cat_num := cat_num + t2 - t1;
- {insert temp array}
- for x := 1 to t2 do
- begin
- cat_array[x + vol_min - 1].fil := temp_array[x].fil;
- cat_array[x + vol_min - 1].sizelo := temp_array[x].sizelo;
- cat_array[x + vol_min - 1].sizehi := temp_array[x].sizehi;
- cat_array[x + vol_min - 1].time := temp_array[x].time;
- cat_array[x + vol_min - 1].date := temp_array[x].date;
- cat_array[x + vol_min - 1].memo := temp_array[x].memo;
- cat_array[x + vol_min - 1].vol_record := t4;
- end;
- end
- else {the temp will fil in the old slot}
- if t1 > t2 then
- begin
- {insert temp array at vol_min}
- for x := 1 to t2 do
- begin
- cat_array[x + vol_min - 1].fil := temp_array[x].fil;
- cat_array[x + vol_min - 1].sizelo := temp_array[x].sizelo;
- cat_array[x + vol_min - 1].sizehi := temp_array[x].sizehi;
- cat_array[x + vol_min - 1].time := temp_array[x].time;
- cat_array[x + vol_min - 1].date := temp_array[x].date;
- cat_array[x + vol_min - 1].memo := temp_array[x].memo;
- cat_array[x + vol_min - 1].vol_record := t4;
- end;
- { move the array down to meet it }
- for x := (vol_max + t2-t1 + 1) to (cat_num + t2 - t1) do
- cat_array[x] := cat_array[x -(t2-t1)];
- cat_num := x;
- end
- else { the replacement array is an exact match !}
- for x := 1 to t2 do
- begin
- cat_array[x + vol_min - 1].fil := temp_array[x].fil;
- cat_array[x + vol_min - 1].sizelo := temp_array[x].sizelo;
- cat_array[x + vol_min - 1].sizehi := temp_array[x].sizehi;
- cat_array[x + vol_min - 1].time := temp_array[x].time;
- cat_array[x + vol_min - 1].date := temp_array[x].date;
- cat_array[x + vol_min - 1].memo := temp_array[x].memo;
- cat_array[x + vol_min - 1].vol_record := t4;
- end;
-
- if cat_num = max_records then writeln ('The catalog is full.');
- end
- else
- begin
- writeln (' Cannot catalog a disk without a Volume Label.');
- writeln (' Use funtion 7 on the Main Menu to add a Volume Label.');
- end;
- EndProc:Dispose(Comments);
- end;
-
- procedure update_disk;
- var choice,c_max:integer;
- tempfile:text;
- sd,ax:boolean;
- begin
- drawbox (10,7,70,24,white,black,'[ Update Disk ]',blink_no);
- found := false;
- writeln;
- writeln ('Place disk in drive ',default_drive,' and press any key...');
- read (kbd,ch);
- volume := '';
- get_vol;
- if volume <> '' then
- begin
- {scan the catalog for volume}
- writeln;
- changed := true;
- for x := 1 to vol_num do
- begin
- if vol_array[x] = volume then
- begin
- found := true;
- t1 := x;
- t4 := x;
- end;
- end;
- if found then { Do a selective update/delete function }
- begin
- writeln ('Disk is already cataloged, performing update.');
- writeln;
- {$I-}
- assign(tempfile,'SDIR.$$$');
- reset(tempfile);
- sd := IOResult=0;
- ax := DIDFileName<>'';
- close(tempfile);
- {$I+}
- writeln ('Disk already cataloged, Options: ');
- writeln(' 1) Use cataloged comments');
- If not sd then
- If ax then
- writeln(' 2) Read AX.COM file') else
- else begin
- writeln(' 2) Read SD.COM file');
- If ax then
- writeln(' 3) Read AX.COM file');
- end; {else}
- c_max := 3;
- If not sd then c_max := 2;
- if not ax then c_max := c_max-1;
- If c_max=1 then choice := 1
- else repeat
- write(' Your choice:');
- readln(choice);
- until choice in [1..c_max];
- If (not sd) and (choice=2) then choice := 3;
- writeln;
- Case choice of
- 2: ReadAxSd(false);
- 3: ReadAxSd(true);
- 1: begin
- vol_min := 0;
- vol_max := 0;
- t2 := 0; { count files found on disk }
- for x := 1 to cat_num do
- if (cat_array[x].vol_record = t1) and (vol_min = 0) then
- vol_min := x
- else
- if (vol_min <> 0 ) and (vol_max = 0) and (cat_array[x].vol_record <> t1) then
- vol_max := x - 1 ;
- if vol_max = 0 then vol_max := cat_num;
- msdos11(3);
- if (r.ax and 255) = 0 then
- begin
- while (r.ax and 255) = 0 do
- begin {q1}
- t2 := t2 + 1;
- temp := '';
- for x := 8 to 18 do
- temp := temp + chr(mem[seg(dta^):ofs(dta^)+x]);
- temp_array[t2].fil := temp;
- temp_array[t2].sizelo[1] := chr(mem[seg(dta^):ofs(dta^)+36]);
- temp_array[t2].sizelo[2] := chr(mem[seg(dta^):ofs(dta^)+37]);
- temp_array[t2].sizehi[1] := chr(mem[seg(dta^):ofs(dta^)+38]);
- temp_array[t2].sizehi[2] := chr(mem[seg(dta^):ofs(dta^)+39]);
- temp_array[t2].time[1] := chr(mem[seg(dta^):ofs(dta^)+30]);
- temp_array[t2].time[2] := chr(mem[seg(dta^):ofs(dta^)+31]);
- temp_array[t2].date[1] := chr(mem[seg(dta^):ofs(dta^)+32]);
- temp_array[t2].date[2] := chr(mem[seg(dta^):ofs(dta^)+33]);
- {-- now find old entry if any --}
- found := false;
- for x := vol_min to vol_max do
- begin
- if cat_array[x].fil = temp then
- begin
- found := true;
- t3 := x;
- end;
- end;
- if not found then
- begin
- write (temp,' ');
- write (' New Memo > ');
- buflen := 33;
- readln (one_memo);
- temp_array[t2].memo := one_memo;
- end
- else
- begin
- writeln (temp,' Memo > ',cat_array[t3].memo);
- write ('Replace [Y/N] ? ');
- repeat read (kbd,ch); until ch in yes_no;
- if upcase(ch) = 'Y' then
- begin
- for q := 1 to 16 do write (chr(8)); clreol;
- write (' New memo > ');
- buflen := 33;
- readln (one_memo);
- temp_array[t2].memo := one_memo;
- end
- else
- begin
- for q := 1 to 16 do write (chr(8)); clreol;
- temp_array[t2].memo := cat_array[t3].memo;
- end;
- end;
- msdos12;
- end
- end;
- writeln ('Updating catalog.. One moment...');
- t1 := vol_max - vol_min + 1;
- if t1 < t2 then
- begin
- {check to see if we will overrun the array}
- if (cat_num + (t2 - t1)) > max_records then
- begin
- writeln ('Maximum of ',max_records,' files exceeded by ',cat_num + t2 - t1 - max_records,'.');
- writeln ('Truncating to ',max_records);
- end;
- {move the file up t2 - t1 records}
- for x := (cat_num + t2 - t1) downto (vol_max + t2-t1 + 1) do
- cat_array[x] := cat_array[x - t2+t1];
- cat_num := cat_num + t2 - t1;
- {insert temp array}
- for x := 1 to t2 do
- begin
- cat_array[x + vol_min - 1].fil := temp_array[x].fil;
- cat_array[x + vol_min - 1].sizelo := temp_array[x].sizelo;
- cat_array[x + vol_min - 1].sizehi := temp_array[x].sizehi;
- cat_array[x + vol_min - 1].time := temp_array[x].time;
- cat_array[x + vol_min - 1].date := temp_array[x].date;
- cat_array[x + vol_min - 1].memo := temp_array[x].memo;
- cat_array[x + vol_min - 1].vol_record := t4;
- end;
- end
- else {the temp will fil in the old slot}
- if t1 > t2 then
- begin
- {insert temp array at vol_min}
- for x := 1 to t2 do
- begin
- cat_array[x + vol_min - 1].fil := temp_array[x].fil;
- cat_array[x + vol_min - 1].sizelo := temp_array[x].sizelo;
- cat_array[x + vol_min - 1].sizehi := temp_array[x].sizehi;
- cat_array[x + vol_min - 1].time := temp_array[x].time;
- cat_array[x + vol_min - 1].date := temp_array[x].date;
- cat_array[x + vol_min - 1].memo := temp_array[x].memo;
- cat_array[x + vol_min - 1].vol_record := t4;
- end;
- { move the array down to meet it }
- for x := (vol_max + t2-t1 + 1) to (cat_num + t2 - t1) do
- cat_array[x] := cat_array[x -(t2-t1)];
- cat_num := x;
- end
- else { the replacement array is an exact match !}
- for x := 1 to t2 do
- begin
- cat_array[x + vol_min - 1].fil := temp_array[x].fil;
- cat_array[x + vol_min - 1].sizelo := temp_array[x].sizelo;
- cat_array[x + vol_min - 1].sizehi := temp_array[x].sizehi;
- cat_array[x + vol_min - 1].time := temp_array[x].time;
- cat_array[x + vol_min - 1].date := temp_array[x].date;
- cat_array[x + vol_min - 1].memo := temp_array[x].memo;
- cat_array[x + vol_min - 1].vol_record := t4;
- end;
- end
- end
- end
- else { Do a Complete Add function }
- begin
- vol_num := vol_num + 1;
- {$I-}
- assign(tempfile,'SDIR.$$$');
- reset(tempfile);
- sd := IOResult=0;
- ax := DIDFileName<>'';
- close(tempfile);
- {$I+}
- writeln ('Disk not cataloged, Options: ');
- writeln(' 1) Enter comments');
- If not sd then
- If ax then
- writeln(' 2) Read AX.COM file') else
- else begin
- writeln(' 2) Read SD.COM file');
- If ax then
- writeln(' 3) Read AX.COM file');
- end; {else}
- c_max := 3;
- If not sd then c_max := 2;
- if not ax then c_max := c_max-1;
- If c_max=1 then choice := 1
- else repeat
- write(' Your choice: ');
- readln(choice);
- until choice in [1..c_max];
- If (not sd) and (choice=2) then choice := 3;
- writeln;
- Case choice of
- 2: ReadAxSd(false);
- 3: ReadAxSd(true);
- 1: begin
- msdos11(3);
- if (r.ax and 255) = 0 then
- begin
- cat_num := cat_num + 1;
- vol_array[vol_num] := volume;
- cat_array[cat_num].vol_record := -1; { -1 means this is a vol entry }
- cat_array[cat_num].fil := volume;
- cat_array[cat_num].memo := 'Volume Label';
- while ((r.ax and 255) = 0) and (cat_num < max_records + 1) do
- begin
- cat_num := cat_num + 1;
- temp := '';
- for x := 8 to 18 do
- temp := temp + chr(mem[seg(dta^):ofs(dta^)+x]);
- write (temp,' ');
- write (' Memo > ');
- buflen := 33;
- readln (one_memo);
- cat_array[cat_num].vol_record := vol_num;
- cat_array[cat_num].fil := temp;
- cat_array[cat_num].sizelo[1] := chr(mem[seg(dta^):ofs(dta^)+36]);
- cat_array[cat_num].sizelo[2] := chr(mem[seg(dta^):ofs(dta^)+37]);
- cat_array[cat_num].sizehi[1] := chr(mem[seg(dta^):ofs(dta^)+38]);
- cat_array[cat_num].sizehi[2] := chr(mem[seg(dta^):ofs(dta^)+39]);
- cat_array[cat_num].time[1] := chr(mem[seg(dta^):ofs(dta^)+30]);
- cat_array[cat_num].time[2] := chr(mem[seg(dta^):ofs(dta^)+31]);
- cat_array[cat_num].date[1] := chr(mem[seg(dta^):ofs(dta^)+32]);
- cat_array[cat_num].date[2] := chr(mem[seg(dta^):ofs(dta^)+33]);
- cat_array[cat_num].memo := one_memo;
- msdos12;
- end {then}
- end {else}
- else
- writeln ('Disk has no files!');
- end {case 1}
- end
- end;
- if cat_num = max_records then writeln ('The catalog is full.');
- end
- else
- begin
- writeln (' Cannot catalog a disk without a Volume Label.');
- writeln (' Use funtion 7 on the Main Menu to add a Volume Label.');
- end;
- write ('Press any key to continue');
- read (kbd,ch);
- end;