


                           Format of Index files

      Index files are named XXX.NDX (where XXX is the conference
      number padded with leading zeros to make it three characters
      long.  There is one *.NDX file for each conference chosen that
      contains messages in the MESSAGES.DAT file.

      The *.NDX file contain records five characters long that point
      to each message in that conference.


      NdxRecord = Record
        MsgPointer: BasicReal
        Conference: Byte;
        End;

      The BasicReal is a four byte number in BASIC MKS$ format.


      The following is a sample program unit for TurboPascal that
      converts between BasicReal format and LongInt format.

------------------------------------------------------------------------------

Unit BasicConvert;

Interface
  Function BasicReal2Long(InValue: LongInt): LongInt;
                {Convert Basic Short Reals to LongInts}

  Function Long2BasicReal(InValue: LongInt): LongInt;
                {Convert LongInts to Basic Short Reals}

Implementation

Function BasicReal2Long(InValue: LongInt): LongInt;

  Var
  Temp: LongInt;
  Negative: Boolean;
  Expon: Integer;

  Begin
    If InValue And $00800000 <> 0 Then
      Negative := True
    Else
      Negative := False;
    Expon := InValue shr 24;
    Expon := Expon and $ff;
    Temp := InValue and $007FFFFF;
    Temp := Temp or $00800000;
    Expon := Expon - 152;
    If Expon < 0 Then Temp := Temp shr Abs(Expon)
      Else Temp := Temp shl Expon;
    If Negative Then
      BasicReal2Long := -Temp
    Else
      BasicReal2Long := Temp;
    If Expon = 0 Then
      BasicReal2Long := 0;
  End;


Function Long2BasicReal(InValue: LongInt): LongInt;
  Var
  Negative: Boolean;
  Expon: LongInt;

  Begin
  If InValue = 0 Then
    Long2BasicReal := 0
  Else
    Begin
    If InValue < 0 Then
      Begin
      Negative := True;
      InValue := Abs(InValue);
      End
    Else
      Negative := False;
    Expon := 152;
    If InValue < $007FFFFF Then
      While ((InValue and $00800000) = 0) Do
        Begin
        InValue := InValue shl 1;
        Dec(Expon);
        End
    Else
      While ((InValue And $FF000000) <> 0) Do
        Begin
        InValue := InValue shr 1;
        Inc(Expon);
        End;
    InValue := InValue And $007FFFFF;
    If Negative Then
      InValue := InValue Or $00800000;
    Long2BasicReal := InValue + (Expon shl 24);
    End;
  End;

End.

------------------------------------------------------------------------------

A quick and dirty conversion (handles positive numbers only) is possible
with the following expression:

MKSToNum := ((x AND NOT $ff000000) OR $00800000)
             SHR (24 - ((x SHR 24) AND $7f));

------------------------------------------------------------------------------

      The number contained in the MsgPointer is the record number
      (128 byte records - starting numbering from record 1 not 0)
      of the message header.  Note that since the 1st record contains
      packet header, the lowest MsgPointer that can exist is 2.

      Some message readers will reformat the *.NDX files so that the
      MsgPointer becomes a LongInt fileseek position (using a record
      size of 1).  To determine which type of index you are reading
      you should look at the size of the number.  Any BasicReal will
      appear as a huge number that would unlikely ever be a byte
      seek positon.


