• filemode

    From Chris Hoppman@1:129/305 to All on Monday, July 05, 2004 09:00:47
    I found the snippet on the html swag that explain'd it.

    http://www.bsdg.org/SWAG/FILES/0003.PAS.html

    now, i am having trouble with blockread/write.

    I want to write to a file using a record that will allow only
    the used length of the vars to be wrote. I did it once before,
    but it was over a year ago and since lost the source (a hd crash)
    and I am tring to reprogram them to work as they once was. I can't
    for the life of me remember how I did it. I think I used a
    pchar in the $x+ state with a array[0..1023] of char linking
    the pchar and the array and using StrPas or StrCopy to copy
    to a string to store in a record.

    I'll figure it out. So far what I have come up with is basicly
    a array of a record with a char defined as the one var in it.


    type
    TBuffer = {$ifdef} virualpascal {$enddef} record
    ch : char;
    end;


    var
    Buffer : array[0..1023] of ^TBuffer;
    PBuffer : PChar;

    Which sucks cause I would have to referance each one with the brackets [xx] buffer[xx].^ch, but would accompish what I want, but I think there is a better way.

    --- Renegade v06-27.4 Alpha
    * Origin: The Titantic BBS Telnet - ttb.slyip.com (1:129/305)
  • From Jasen Betts@3:640/1042 to Chris Hoppman on Tuesday, July 06, 2004 20:07:05
    Hello Chris.

    05 Jul 04 08:00, you wrote to all:

    I found the snippet on the html swag that explain'd it.

    http://www.bsdg.org/SWAG/FILES/0003.PAS.html

    now, i am having trouble with blockread/write.

    I want to write to a file using a record that will allow only
    the used length of the vars to be wrote.

    that sounds like it would need variable length records in the file,
    so yeah using type file and blockread/blockwrite is the right start.

    for reading and writing you can either compose all the fileds together into an array of bytes (or chars etc) and write it in a single operation or read and write the fields indiidually.

    for the life of me remember how I did it. I think I used a
    pchar in the $x+ state with a array[0..1023] of char linking
    the pchar and the array and using StrPas or StrCopy to copy
    to a string to store in a record.

    Sounds like the first method.

    type
    TBuffer = {$ifdef} virualpascal {$enddef} record
    ch : char;
    end;


    var
    Buffer : array[0..1023] of ^TBuffer;
    PBuffer : PChar;

    Which sucks cause I would have to referance each one with the
    brackets
    [xx] buffer[xx].^ch, but would accompish what I want, but I think
    there is a better way.

    Why do you want an array of pointers? (i think it should be an array of char)

    Jasen

    --- GoldED+/LNX 1.1.4.7
    * Origin: (3:640/1042)
  • From Chris Hoppman@1:129/305 to Jasen Betts on Thursday, July 08, 2004 04:16:50
    var
    Buffer : array[0..1023] of ^TBuffer;
    PBuffer : PChar;

    ended up doing it like.

    type
    BufferArr : array[0..1023] of char; {1024 pascal writes smoother with that} var
    Buffer : ^BufferPtr;


    Then just not reset(tbufferfile,XX) each time.. Just inilize it once then
    move on. Someone in the news groups clear'd it up that it isn't bytes it
    is writing, but records. So, I understood after that and came to this conclution. and yes this is exactly what I did last time, because I was wokring with the *.msg format at the time (now I remember) and saw that is how you had to read in the message part of the netmail/*.msg message.. ;)


    Thank you for all your help.

    Chris Hoppman

    --- Renegade v06-27.4 Alpha
    * Origin: The Titantic BBS Telnet - ttb.slyip.com (1:129/305)