Results 1 to 4 of 4

Thread: Need some help / advice with reading from streams

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Need some help / advice with reading from streams

    Hi all.
    Dunno if anybody even answers here but i try.

    In short:
    If i write structs (UndoBlock) to streams like that:
    hugestream.Write(UndoBlock, sizeof(UndoBlock));
    This "kinda" works. Data is written and it seems that its written correctly.

    But i have a real problem reading it back.
    Do i need to read into array?
    The amount of writings depends on how many changes user made to the map.
    I can count that..

    But when im trying to read the numwritten i get garbage.
    Writing to stream (im just saving old block before modifying):
    hugestream.Write(sbs, sizeof(sbs));
    Reading back:
      for i:=0 to NumWritten-1 do
      begin, sizeof(sbs)); // is this even correct way to read???
       ShowMessage('setstate '+IntToStr(sbs.LidTile));  // garbage displayed
    The cbs record only has Byte and Word fields. Nothing else.
    maybe the record size is bad? Maybe i should add "pad"?

    Or i just should read back every record item (field) one by one and not whole struct at once?

    I have used lots of streams and stuff in my other projects but i always get the issues reading back stuff.
    Im forgetting stuff.
    Last edited by hwnd; 07-07-2019 at 03:52 PM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Comodo SSL