Subj : Final code
To   : mark lewis
From : Sean Dennis
Date : Fri May 07 2010 11:18 pm

Hello, mark.

Friday May 07 2010 at 10:17, you wrote to me:

ml> here's another post that only pulls out the space delimited fields and
ml> this one is zero-based... field 0 is 'A', 1 is 'Daryl', 3 is the comma
ml> delimited section and so on...

Thanks for the code; I'll keep it in my archives.

I don't normally post my code "out in the open", but I only think it's right
since it's based on what you did.  I need to do a bit more error checking in
this code.  You'll see calls to functions that I use in my doorkit unit, but I
think you'll get the jist of it:

===Cut===
{ -------------------------------------------------------------------
 PROCEDURE ReadGTUSER(Path : String);
 Reads and parses GTUSER.BBS properly for use with my doors
 Based on code written by Mark Lewis
 ------------------------------------------------------------------- }
Procedure ReadGTUSER(Path : String);
Var
 Count : Integer;
 Gtstr, Result_Str, Tempdata : String;
 Gtfile : Text;

 Function ExtractWord(Str : String; N : Integer) : String;
Var
  Count, I , Len : Integer;
  Done : Boolean;
  Retstr : String;
Begin
  Retstr := '';
  Len := Length(Str);
  Count := 0;
  I := 1;
  Done := False;
  While (I <= Len) And (Not Done) Do
    Begin
      While ((I <= Len) And
             ((Str[I] = #32) Or
              (Str[I] = #9) Or
              (Str[I] = ':'))) Do
        Inc(I);
      If I <= Len Then
        Inc(Count);
      If Count = N Then
        Begin
          Retstr[0] := #0;
          If (I > 1) Then
            If Str[I-1] = ';' Then
              Retstr := ';';
          While ((I <= Len) And
                 ((Str[I] <> #32) And
                  (Str[I] <> #9) And
                  (Str[I] <> ':'))) Do
            Begin
              Inc(Retstr[0]);
              Retstr[Ord(Retstr[0])] := Str[I];
              Inc(I);
            End;
          Done := True;
        End
      Else
        While ((I <= Len) And
               ((Str[I] <> #32) And
                (Str[I] <> #9) And
                (Str[I] <> ':'))) Do
          Inc(I);
    End;
  Extractword := Retstr;
End;

Begin
 Assign(GTFile, Path + 'gtuser.bbs');
 {$I-}Reset(GTFile);{$I+}
 ReadLn(GTFile, GTStr);
 Close(GTFile);
 { This is /really/ ugly, but there's really no better
   way to do what I want to do. The comport and node
   number have been set elsewhere, but we need to check the comport
   setting to make sure it's right.}
   If (fk_Fossil.Port = 0) Then
     Begin
       ClrScr;
       NL;
       pWriteLn('|12WARNING: |14Comport not set on command line for
GTUSER.BBS!|07');
       fk_DeInitFossil;
     End;
   Count := 2;
 { Read in the first name and last name then concatenate
   together for FKFOSSIL }
   TempData := '';
   TempData := ExtractWord(GTStr, Count);
   Inc(Count);
   TempData := TempData + ' ' + ExtractWord(GTStr, Count);
   fk_Client.Name := TempData;
   TempData := '';
 { Jump to the DCE rate }
   Count := Count + 7;
   fk_Fossil.Baud := StrToInt(ExtractWord(GTStr, Count));
   Inc(Count);
 { Determine if ANSI is used or not }
   TempData := ExtractWord(GTStr, Count);
   If (TempData = 'ANSI') or (TempData = 'RIPSCRIP') Then
     fk_Client.ScreenType := 1 Else fk_Client.ScreenType := 0;
 { Time left for this call }
   Count := Count + 2;
   fk_Client.TimeLeft := StrToInt(ExtractWord(GTStr, Count));
End; === Cut ===

Later,
Sean

//[email protected] | http://nsbbs.info | ICQ: 19965647

... Friends may come and go, but enemies accumulate.
--- GoldED/2 3.0.1
* Origin: Nocturnal State BBS - (423) 926-7999 - bbs.nsbbs.info (1:18/200)