unit      MsgXtr;

{$A+}     { Word Align Data             }
{$B-}     { Shortcut Boolean Evaluation }
{$E+}     { 8087 Emulation              }  {®N}
{$Y+}     { Symbol Information          }  {®L,D}
{$L+}     { Local Symbol Information    }  {®D} {¯Y}
{$V-}     { No Strict Var-String Check  }
{$N-}     { Do Not Use 8087             }  {¯E}
{$O-}     { Overlays Not Allowed        }
{$F-}     { Force Far Calls Disabled    }
{$X-}     { Extended Syntax Disabled    }
{$P-}     { Open Strings Disabled       }
{$G+}     { 80286 Code Generation       }
{$I+}     { I/O Checking                }
{$S-}     { Stack Checking Disabled     }  {D+}
{$Q-}     { Overflow Checking Disabled  }  {D+}
{$R-}     { Range Checking Disabled     }  {D+}
{$D+}     { Debug Information Disabled  }  {D+} {¯L,Y}
{$T-}     { @ Allways Returns Untyped   }
{$W-}     { Windows Frame Disabled      }

interface

uses       MkMsgAbs,MkGlobT;

procedure  GetCompleteAddresses(var M:AbsMsgPtr;var A1,A2:AddrType);

implementation

uses       UStrings;

procedure  GetCompleteAddresses(var M:AbsMsgPtr;var A1,A2:AddrType);

  var      S  :  string;
           P  :  longint;

  function  GetPoint(O:word):word;

    var      W  :  word;
             I  :  integer;

    begin
      val(DelSpaces(copy(S,7,255)),W,I);
      if I=0 then
        GetPoint:=W
       else
        GetPoint:=O;
    end;

  procedure  GetINTL;

    var      AA  :  AddrType;
             S1  :  string;

    begin
      S:=DelSpaces(copy(S,7,255));
      S1:=copy(S,1,pos(' ',S)-1);
      S:=copy(S,length(S1)+2,255);
      if ParseAddr(S,A1,AA) then begin
        A1.Zone:=AA.Zone;
        A1.Net:=AA.Net;
        A1.Node:=AA.Node;
      end;
      if ParseAddr(S1,A2,AA) then begin
        A2.Zone:=AA.Zone;
        A2.Net:=AA.Net;
        A2.Node:=AA.Node;
      end;
    end;

  procedure  GetOrigin;

    var      B  : byte;
             A  : AddrType;

    begin
      B:=length(S);
      while (S[B]<>'(') and (B>0) do
        dec(B);
      if B>0 then begin
        S:=DelSpaces(copy(S,B,255));
        if (S[length(S)]=')') and ParseAddr(copy(S,1,length(S)-1),A2,A) then
          move(A,A2,sizeof(AddrType));
      end;
    end;

  begin
    P:=M^.GetTxtPos;
    M^.GetDest(A1);
    M^.GetOrig(A2);
    while not M^.EOM do begin
      S:=M^.GetString(255);
      if (S[0]>#0) and (S[1]=^A) then begin
        if pos('TOPT ',S)=2 then
          A1.Point:=GetPoint(A1.Point)
         else if pos('FMPT ',S)=2 then
          A2.Point:=GetPoint(A2.Point)
         else if pos('INTL ',S)=2 then
          GetINTL;
       end else if pos(' * Origin: ',S)=1 then
        GetOrigin;
    end;
    M^.SetTxtPos(P);
  end;

end.
