Conceptually the idea is something like (not real Livecode):
Code: Select all
put arrayEncode(array1) into binarray1
write binarray1 to file outputFile
put arrayEncode(array2) into binarray2
write binarray2 to file outputFile at ... [end? some byte position?]
1. Get the size in bytes of each array and structure the file as something like:
[integer: number of arrays in file][long integer: length of first encoded array][long integer: length of second encoded array]...[binary blob: start of first encoded array][binary blob: start of second encoded array]
So the writing handler would need to encode each array, calculate the byte length of each encoded array, and then write to the file: the number of arrays, the byte size of each array, then each array. The reading handler would then need to read in the same order, extracting out each blob and decoding it.
If I use this method how do I:
A. Ensure that I write a number out as an integer?
B. Determine the exact size of an encoded array?
2. Write each encoded array followed by a marker, which in turn can be found when reading. This seems problematic as any character you choose as a marker could theoretically be in the encoding of the array.
3. Put all of the arrays into a single array before encoding.
Code: Select all
put array1 into megaArray[1]
put array2 into megaArray[2]
...
put encodeArray(megaArray) into megaBinArray
So, my question for the Wed Q&A is to see an example of something like this or have a discussion about the concept. I figure that there is some function, command, or keyword I am unaware of that makes this tedious exercise in other languages trivial in Livecode.
Regards,
Dale