Announcement

Collapse
No announcement yet.

Saving Arrays

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Saving Arrays

    Hello,

    does anyone know how to

    change the contence of a stringarray to a string or to disk
    very quickly ???

    Thanks for answere.

    Matthias Kuhn


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

  • #2
    Since Dynamic strings move around in memory with each string assignment, the contents of a dynamic string array will not form a single large block of memory. In other words, they will not be stored exactly "sequentially" in memory.

    So, for a Dynamic string array, you have to read each individual array element from the string array and then write it to disk (or concatenate a few together and write them as one operation).

    Likewise, when reading a dynamic strings from disk, the memory has to first be reserved for each string, and this will be allocated in the first string block that contains enough free space for the string.

    This means you have to either read/write strings individually, or say, read a large block of the disk file (say, up to the $STRING size) and parse the individual strings from that block once it is in memory. Reading and writing large blocks from/to disk files is usually always faster than reading/writing line by line, but it requires more code and more memory during the operation.

    There is no simple way around this fact as far as dynamic strings go... sorry!

    Maybe if you can tell us what sort of data are you wanting to load/save, we may be able to offer more specific advice or an alogrithm that will speed up your code.

    For example, if your data could be stored in a different manner, it may make the block read/write operation much easier to handle.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment

    Working...
    X