• Final code

    From Sean Dennis@1:18/200 to Mark Lewis on Thu May 6 21:09:55 2010
    Hello, Mark.

    I couldn't resist relaxing a bit and working on some code, so I got the code finalized and it compiles. Now to see if it actually works. :)
    Later,
    Sean

    //sean@nsbbs.info | http://nsbbs.info | ICQ: 19965647

    ... I must have slipped a disk - my pack hurts.
    --- GoldED/2 3.0.1
    * Origin: Nocturnal State BBS - (423) 926-7999 - bbs.nsbbs.info (1:18/200)
  • From mark lewis@1:3634/12 to Sean Dennis on Fri May 7 10:17:48 2010

    I couldn't resist relaxing a bit and working on some code, so I got
    the code finalized and it compiles. Now to see if it actually
    works. :)

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

    another item of interest about this routine... it looks like, by default, it extracts words that are space, tab or semi-colon (;) delimited... but anyway, there it is :)

    program extract_word_test;

    const
    t1_str : string = 'A Daryl Stout SY,SH,KL,DR,DN,UP,';
    t2_str : string = 'PR,MS,MMV,CC,RC,PW,CU,QK,MB,MU,CB,';
    t3_str : string = 'TB=05/05/02/01/03/01/01/60/60:120/120 ';
    t4_str : string = 'LOCAL ANSI 5-4-10 4880 307 18:53';

    var
    my_cnt : integer;
    my_str,
    result_str : string;

    function extractword(str : string; n : integer) : string;
    var
    count : integer;
    i : integer;
    len : integer;
    done : boolean;
    retstr : string;

    begin
    retstr := '';
    len := length(str);
    count := -1;
    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
    my_str := t1_str + t2_str + t3_str + t4_str;
    writeln(my_str);
    for my_cnt := 0 to 9 do
    begin
    result_str := extractword(my_str,my_cnt);
    writeln(my_cnt, ' : ''',result_str,'''');
    end;
    end.


    * Origin: (1:3634/12)
  • From Sean Dennis@1:18/200 to mark lewis on Fri May 7 23:18:51 2010
    Hello, mark.

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

    here's another post that only pulls out the space delimited fields and this one is zero-based... field 0 is 'A', 1 is 'Daryl', 3 is the comma 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

    //sean@nsbbs.info | 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)
  • From mark lewis@1:3634/12 to Sean Dennis on Sat May 8 12:24:40 2010

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

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

    :) i've quite a large lib of raw sources that i have to dig thru from time to time... i've forgotten over half of what i have and a lot of it is old, too... like 1992 PASCAL echo postings... i've several from DJ Murdoch and a few other "old timers" from that period ;)

    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:

    looks good! maybe a few suggestions?

    ===Cut===

    [trim]

    ((Str[I] = #32) Or
    (Str[I] = #9) Or
    (Str[I] = ':'))) Do

    these were originally ';' (semicolon)... i'm not sure (off hand) what they are specifically used for but there is other code in ExtractWord that specifically looks for and includes it in the string...

    Count := 2;
    { Read in the first name and last name then concatenate
    together for FKFOSSIL }
    from here
    TempData := '';
    TempData := ExtractWord(GTStr, Count);
    Inc(Count);
    TempData := TempData + ' ' + ExtractWord(GTStr, Count);
    fk_Client.Name := TempData;
    to here
    change to

    fk_Client.Name := ExtractWord(GTStr,2) + ' ' + ExtractWord(GTStr,3);
    Inc(Count);

    saves three moves of data back and forth ;) i would probably also just use the numbers in the ExtractWord calls instead of messing with the count var...

    TempData := '';
    { Jump to the DCE rate }
    Count := Count + 7;
    fk_Fossil.Baud := StrToInt(ExtractWord(GTStr, Count));

    fk_Fossil.Baud := StrToInt(ExtractWord(GTStr,10));

    Inc(Count);
    { Determine if ANSI is used or not }
    TempData := ExtractWord(GTStr, Count);

    TempData := ExtractWord(GTStr,11);

    If (TempData = 'ANSI') or (TempData = 'RIPSCRIP') Then
    fk_Client.ScreenType := 1 Else fk_Client.ScreenType := 0; {

    //i think// this one can also be done as a boolean on one line... but i forget if true is one or zero...

    fk_Client.ScreenType := ((TempData = 'ANSI') or (TempData = 'RIPSCRIP'));

    but i may be getting that mixed up with another language :/ if not, it might even be possible to put the calls to ExtractWord in there and forego the use of
    TempData completely...

    fk_Client.ScreenType := ((ExtractWord(GTStr,11)='ANSI')or(ExtractWord(GTStr,11)='RIPSCRIP'));

    it has been a while :lol:

    Time left for this call }
    Count := Count + 2;
    fk_Client.TimeLeft := StrToInt(ExtractWord(GTStr, Count)); End;

    fk_Client.TimeLeft := StrToInt(ExtractWord(GTStr,13));
    End;

    )\/(ark


    * Origin: (1:3634/12)
  • From mark lewis@1:3634/12 to Sean Dennis on Sat May 8 13:13:16 2010

    but i may be getting that mixed up with another language :/ if not,
    it might even be possible to put the calls to ExtractWord in there
    and forego the use of TempData completely...

    fk_Client.ScreenType := ((ExtractWord(GTStr,11)='ANSI')or(ExtractWord(GTStr,11)='RIPSCRIP')
    );

    i didn't get mixed up or forget :) the above is OK and works... only needs to have 'ord' added since you need a 1 or a 0... so...

    fk_Client.ScreenType := ord((ExtractWord(GTStr,11)='ANSI')or(ExtractWord(GTStr,11)='RIPSCRIP'));

    and it returns a 1 as desired with 'ANSI' or 'RIPSCRIP' and 0 with anything else (ie: MONO)... if a three state is needed, then using a boolean like this won't work but it is a quick and neat use of code "shortcuts" ;)

    )\/ark


    * Origin: (1:3634/12)
  • From mark lewis@1:3634/12 to Sean Dennis on Sat May 8 13:25:20 2010

    fk_Client.ScreenType := ord((ExtractWord(GTStr,11)='ANSI')or(ExtractWord(GTStr,11)='RIPSCRI
    P'));

    and it returns a 1 as desired with 'ANSI' or 'RIPSCRIP' and 0 with anything else (ie: MONO)... if a three state is needed, then using
    a boolean like this won't work but it is a quick and neat use of
    code "shortcuts" ;)

    OH YES! watch your numbers, too... i switched my extractword to being zero based and restored it to using the ';' (not ':' colon as you posted) for space delimited work... the above ANSI field is 5 (zero based) or 6 (one based)... i tripped on it at first due to the differences since my first post so i wrote a quick test which showed me it was not grabbing the proper field...

    )\/(ark


    * Origin: (1:3634/12)
  • From John Guillory@1:135/364 to mark lewis on Wed Jun 16 21:38:39 2010
    °·. Regarding : Final code .·°
    °·. Reply Requested? Yes, Please Reply. .·°

    ┌──°·. mark lewis whispered this to Sean Dennis...
    │ time... i've forgotten over half of what i have and a lot of it is old, too.. │ like 1992 PASCAL echo postings... i've several from DJ Murdoch and a few othe │ "old timers" from that period ;)
    └──.·° Out of the stillness, john guillory said this...

    If you've got some pascal code from DJ Murdoch, chances are you probably have some code in there that I wrote.... I remember DJ Murdoch in the Pascal Echo.... This echo really rocked when he was around! ;-) Granted, it's been
    a while since I've seen this echo having any messages.... Good to see it
    being used.... Question about this echo ... I've got pascal_lessons on my
    BBS, but can't get pascal from Marc Lewis.... I notice these messages are
    40 days old, did it get canned for no activity?
    If not, anyone know where I can get a feed for it?

    --- Virtual Advanced Ver 2 for DOS
    * Origin: Deep Space 69 BBS - telnet://ds69bbs.com - Florida (1:135/364)
  • From mark lewis@1:3634/12 to John Guillory on Mon Jun 21 23:19:30 2010

    If you've got some pascal code from DJ Murdoch, chances are you
    probably have some code in there that I wrote....

    not only DJ but TJ as well (IIRC)...

    I remember DJ Murdoch in the Pascal Echo.... This echo really
    rocked when he was around! ;-) Granted, it's been a while since
    I've seen this echo having any messages.... Good to see it being
    used.... Question about this echo ... I've got pascal_lessons on
    my BBS, but can't get pascal from Marc Lewis.... I notice these
    messages are >40 days old, did it get canned for no activity?
    If not, anyone know where I can get a feed for it?

    dunno why you can't get PASCAL from marc's place... it might have been dropped but i'd have to go looking back to see if there are postings at least once a month or not...

    in any case, if anyone needs a feed for something, they can acquire my service.app (i think that's the one), fill it out and netmail it back to me and
    i'll get them set up... i do require password protected sessions from my downlinks, though... some systems can't do that or do it properly but in any case, the offer is there ;)

    )\/(ark


    * Origin: (1:3634/12)