DATAPROC.PAS

3.9 KB dd34cf87a81473b2…
{
 MCi Code routines written for data areas, logon config, file system,
 menuing system, etc, etc .. gains x/y pos, attribs, etc from mci files.

 written on sept 9th, 1998 by skaboy101
}
{$I DIRECT.INC}
unit dataproc;
     interface uses dos,gentypes,subs1,subs2,gensubs,configrt,modem,fileLock,
                    dosmem,crt;
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
const
 dMaxCodes   = 25;
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
type
 dMciDataRec = record
        code : string[2];
        attr : byte;
        xPos : byte;
        yPos : byte;
 end;
 dMciArray   = array[1..dMaxCodes] of dMciDataRec;
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
var
 dMciData    : ^dMciArray;
 dMciTotal   : 0..dMaxCodes;
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
procedure dInitMciMem(init : boolean);
procedure dResetMciCodes;
procedure dAddMciCode(code : string);
procedure dShowMciFile(fileName : string);
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
implementation
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
procedure dInitMciMem(init : boolean);
 begin
 if (init=true) then
  begin
  new(dMciData);
  fillChar(dMciData^,sizeOf(dMciData^),0);
  end else
   dispose(dMciData);
 end;
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
procedure dResetMciCodes;
var dCount : byte;
 begin
 dMciTotal := 0;
 fillChar(dMciData^,sizeOf(dMciData^),0);
 for dCount := 1 to dMaxCodes do
  begin
  dMciData^[dCount].xPos := 1;
  dMciData^[dCount].yPos := 1;
  dMciData^[dCount].attr := 7;
  end;
 end;
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
procedure dAddMciCode(code : string);
 begin
 if (dMciTotal<dMaxCodes) then
  begin
  inc(dMciTotal);
  dMciData^[dMciTotal].code := upString(code);
  end;
 end;
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
procedure dShowMciFile(fileName : string);
type dBuffArray = array[1..4096] of char;
var  dFile      : file;
     dCount     : word;
     dBuff      : dBuffArray;
     dRead      : word;
     dCode      : string[2];
     dFound     : boolean;

  procedure dShowChar(ch : char);
   begin
    if (online=true) then sendChar(ch);
    writeCon(ch);
   end;

  procedure dParseRange;
  var dMciCount : word;
      dCode     : string[2];
      dTemp     : shortInt;
      dFound    : boolean;
   begin
   dCount := 1;
    while (dCount<=dRead) and (hungUpOn=false) and (dBuff[dCount]<>#26) do
     begin
     if (dBuff[dCount]='|') then
      begin
      dFound := false;
      dCode := dBuff[dCount+1]+dBuff[dCount+2];
      for dMciCount := 1 to dMciTotal do
       begin
       if (match(dCode,dMciData^[dMciCount].code)=true) then
        begin
        dMciData^[dMciCount].xPos := whereX;
        dMciData^[dMciCount].yPos := whereY;
        dMciData^[dMciCount].attr := textAttr;
        inc(dCount,2); for dTemp := 1 to 3 do dShowChar(' ');
        dFound := true;
        end;
       end;
      if not dFound then dShowChar('|');
      end else dShowChar(dBuff[dCount]);
     inc(dCount);
     end;
   end;

 begin
 fileName := correct_dir(cfg.textFileDir+fileName);
 if not exist(fileName) then
  begin
  sendCr(^M'Error, Infusion cannot find the datainput file '+fileName);
  sendCr('Please notify sysop of this...');
  exit;
  end;
{ dos_getMem(dBuff,sizeOf(dBuffArray));}
 nAssign(dFile,fileName);
 reset(dFile,1);
  repeat
  fillChar(dBuff,sizeOf(dBuff),0);
  nBlockRead(dFile,dBuff,sizeOf(dBuff),dRead);
  dParseRange;
  until (eof(dFile)=true) or (hungUpOn=true) or (dRead<1);
{ dos_freeMem(dBuff);}
 nClose(dFile);
 end;
{::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
begin end.