Category : Modula II Source Code
Archive   : HISTRPT.ZIP
Filename : MCHIST.MOD

 
Output of file : MCHIST.MOD contained in archive : HISTRPT.ZIP
IMPLEMENTATION MODULE MCHIST;

PROCEDURE HSearch(Strng:Str16):LONGCARD;

LABEL QUIT;
VAR
result,
filesize,
buffsize,
recs,
lrec,
start,
endr,
peek : LONGCARD;
cresult : INTEGER;
nread : CARDINAL;
out : BOOLEAN;

BEGIN
out := FALSE;
buffsize := SIZE(HNX);
filesize := Size(HN);
recs := filesize DIV buffsize;
lrec := filesize - buffsize;
start := 0;
endr := recs;
peek := endr DIV 2;

Seek(HN,start);
nread := RdBin(HN,HNX,VAL(CARDINAL,buffsize));
cresult := Compare(Strng,HNX.item);
IF cresult = 0 THEN
result := HNX.recnum;
GOTO QUIT;
END;
Seek(HN,endr);
nread := RdBin(HN,HNX,VAL(CARDINAL,buffsize));
cresult := Compare(Strng,HNX.item);
IF cresult = 0 THEN
result := HNX.recnum;
GOTO QUIT;
END;
REPEAT
IF start + 1 # endr THEN
Seek(HN,peek*buffsize);
nread := RdBin(HN,HNX,VAL(CARDINAL,buffsize));
cresult := Compare(Strng,HNX.item);
CASE cresult OF
1 : start := peek;
peek := ((endr-start) DIV 2) + start|
0 : result := HNX.recnum;
out := TRUE|
-1 : endr := peek;
peek := ((endr-start) DIV 2) + start|
END;
ELSE
result := MAX(LONGCARD);
out := TRUE;
END;
UNTIL out;
QUIT:
RETURN result;
END HSearch;

PROCEDURE MakeHistIndex;
VAR
buffsize,
filesize,
recs,
lrec,
i : LONGCARD;
counter,
ibuffsize,
nread : CARDINAL;
cresult : INTEGER;
ch : CHAR;
delrecord : BYTE;

BEGIN
delrecord := 0FFH;
buffsize := SIZE(HIST);
ibuffsize := SIZE(HNX);
filesize := Size(HFILE)-buffsize;
recs := filesize DIV buffsize;
lrec := recs * buffsize;
WrStr('Creating index file for ICHIST.00');
WrLn;
WrStr('Filesize of ICHIST.00: ');
WrLngCard(filesize,9);
WrLn;
WrStr('Records to process: ');
WrLngCard(recs,6);
WrLn;
GotoXY(35,11);
WrStr('Processing record');
counter := 1;
i := 0;
WHILE i <= lrec DO
Seek(HFILE,i);
GotoXY(38,13);
WrCard(counter,5);
nread := RdBin(HFILE,HIST,VAL(CARDINAL,buffsize));
IF HIST.status # delrecord THEN
HNX.recnum := i;
HNX.item := HIST.item;
WrBin(HN,HNX,ibuffsize);
END;
INC(counter);
INC(i,buffsize);
END;
END MakeHistIndex;

END MCHIST.

  3 Responses to “Category : Modula II Source Code
Archive   : HISTRPT.ZIP
Filename : MCHIST.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/