home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG094.ARC
/
NMANGR2.PRO
< prev
next >
Wrap
Text File
|
1979-12-31
|
5KB
|
153 lines
Function GetBlock(Index,ExtentNo,BlockNo:integer ;Var NDirIndex:integer):integer;
Var
WorkSpaceName:string[12];
DirIx:integer;
begin
NDirIndex:=-1;
DirIx:=dirIndex[Index];
WorkSpaceName:=Directory[DirIx].Dname;
DirIx:=DirIx+ExtentNo;
If (DirIx<=EndOfDirectory)
and (WorkSpaceName=Directory[DirIx].Dname) then
begin
with Directory[DirIx] do
begin
NDirIndex:=DirIx;
GetRecord(DriveSelected,Dtrack,Dsector);
GetBlock:=DMA[Doffset+16+BlockNo]
end
end
else GetBlock:=0
end;
Function RecordNo(WSpFileRecNo,Index:integer):integer;
Var
RecInBlock,RecInExtnt,ExtentNo,
MaxRec,BlockNo,Block,NDirIndex:integer;
Const
LogExtnts=1; { 1 shl EXM (for WorkSpace EXM = 0)
the number of logical extents in a physical extent}
begin
If WSpFileRecNo>=0 then
begin
ExtentNo:=WSpFileRecNo div 128; {records in 16k (a WorkSpace Phys Extent)}
RecInExtnt :=WSpFileRecNo mod 128;
BlockNo :=RecInExtnt div 16; {records in 2k block use by WorkSpace}
RecInBlock :=RecInExtnt mod 16;
Block:=getBlock(Index,ExtentNo,BlockNo,NDirIndex);
If Block<>0
Then with Directory[NDirIndex] do
MaxRec:= ((DMA[Doffset+$0C] mod LogExtnts) shl 7 )+DMA[Doffset+$0F];
end;
If (Block<>0) and (RecInExtnt<MaxRec) and (WSpFileRecNo>=0) then
RecordNo:=Block*16+RecInBlock
else
recordNo:=-1;
end;
Procedure LocateRecInFile( Index:integer;RecNo:integer;
Var Okay:Boolean;
Var Track,Sector:integer);
Var
ExtSz,BlkSz,RecInExtnt,ExtentNo,BlockNo,Block,NDirIndex,
MaxRec,LogExtnts:integer;
BigDrv:boolean;
DirBlocks:BlockData;
begin
Okay:=True;
BlkSz:=1 shl BSH; {records in block }
ExtSz:= BlkSz shl 3; {records in Physical Extent)}
BigDrv:=DSM>$FF;
If not(BigDrv) then ExtSz:=ExtSz shl 1;
LogExtnts:=ExtSz div 128; {No of Logical extnts in a Physical Extent}
ExtentNo:= RecNo div ExtSz;
RecInExtnt := RecNo mod ExtSz;
BlockNo :=0;
Block:=getBlock(Index,ExtentNo,BlockNo,NDirIndex);{finds correct extent}
If Block=0 then Begin Writeln(' **** Record Error in WorkSpace**** ');halt;end;
with Directory[NDirIndex] do for loop:=0 to 15 do begin
DirBlocks[loop]:=DMA[Doffset+16+loop];
MaxRec:= ((DMA[Doffset+$0C] mod LogExtnts) shl 7 )+DMA[Doffset+$0F];
end;
If RecInExtnt>=MaxRec then Okay:=False;
LocateRecord(DirBlocks,RecInExtnt,Track,Sector,BigDrv);
end;
Procedure DisplayWSPFile(WSpIndex,Index:integer);
Var
Resp:Char;
Okay:boolean;
ORecrd,Recrd,FRecrd,Error:Integer;
RecrdR:Real;
RecrdStr:String[5];
Const
Cmd=16;
Begin
ClrScr;
Write('Drive = ',DriveStr,' WrkSp = ',Directory[DirIndex[WSpIndex]].Dname);
Writeln(' File = ',Directory[DirIndex[Index]].Dname);
Recrd:=0;RecrdR:=0;
FRecrd:= RecordNo(Recrd,Index);
If FRecrd>=0 then
repeat
ORecrd:=Recrd;
LocateRecinFile(WSpIndex,FRecrd,Okay,Track,Sector);
If Not(Okay) then begin
GotoXY(1,Cmd);
Writeln('*** Error in Record No *** ')
end;
getRecord(DriveSelected,Track,Sector);
GotoXY(1,2);
Writeln(' Track = ',Track,' Sector = ',Sector,' Record = ',RecrdR:5:0,' ');
GotoXY(1,4);
DisplaySector(SectorData);
GotoXY(1,Cmd);
Writeln('Commands => ESC, +, -, R, P ' );
repeat
Read(Kbd,Resp);
until Resp in [#27,'+',';','-','=','R','r','P','p'];
Case Resp of
'P','p':ScreenDump;
'+',';':RecrdR:=RecrdR+1;
'-','=':RecrdR:=RecrdR-1;
'R','r':begin
Repeat
GotoXY(1,Cmd);
Write(' ');
GotoXY(1,Cmd);
Write('Which record number please ? ');
BufLen:=5;
Read(RecrdStr);
Val(RecrdStr,RecrdR,Error);
WriteLn(' ');
until (Error=0) and (RecrdR>=0) and (RecrdR<=65535.0)
end;
end;
If RecrdR>32767
then Recrd:=Trunc(RecrdR-65536.0)
else Recrd:=Trunc(RecrdR);
FRecrd:= RecordNo(Recrd,Index);
If FRecrd=-1 then
begin
Recrd:=ORecrd;
RecrdR:=ORecrd;
GotoXY(1,Cmd);
WriteLn('**** ERROR in record no. **** ');
Delay(1500);
Recrd:=ORecrd;
FRecrd:= RecordNo(Recrd,Index);
end
until Resp=#27
else
begin
Writeln('***** This File is EMPTY ***** ');
Delay(2000);
end;
end;