Page 1 of 1

using binfile vs file for arrayencoding save to file

Posted: Tue Jan 13, 2015 11:25 am
by Coffee1633
Recently I started saving progress data to the docs folder on mobile, no problems. But I just wanted to check a few things.
I was wondering whether it is necessary to use "binfile" or can I just use "file". The caveat is that the progress data is an array as you can see from the code snipet below. First I arrayencode the array var and then store it in the docs folder on mobile but I use "binfile" instead of "file". I actually got the same results just with "file" but because of the following arrayEncode dic entry I use "binfile".

"The arrayEncode function returns a string of binary data that represents the data and structure of the specified array."

Code: Select all

put arrayencode ( sProgressA ) into URL ( "binfile:" & specialFolderPath ( "documents" ) & slash & tFilepath )
also from the dic entry
"version - If present, and >= "7.0" then the array is encoded in such a way as to preserve unicode in keys and values, as well as NUL chars in keys and values"

I was also wondering what format the version parameter should take. Could it be just "7" or should it be "7.0" or do I have to put "7.0.1". Also, what if I put "7.0" and then update to 7.1 someday and forget to change the version. I mean how much versioning do I have to specify?

Re: using binfile vs file for arrayencoding save to file

Posted: Tue Jan 13, 2015 1:44 pm
by Klaus
Hi Coffee1633,

I you think that the OFFICIAL way is only there to make your life harder,
then you should always use FILE for your BINARY ARRAY DATA! 8)

There is a change in the FILEFORMAT with LC >= 7.x, so checking for -> the version >= 7... should do.


Best

Klaus

Re: using binfile vs file for arrayencoding save to file

Posted: Tue Jan 13, 2015 2:08 pm
by bn
Hi Coffee,

Klaus wrote:
I you think that the OFFICIAL way is only there to make your life harder,
then you should always use FILE for your BINARY ARRAY DATA! 8)
Klaus is being ironic here. He means of course you should follow the official recommendation.

And there is a reason for it: If you use file Livecode turns lineendings into the lineendings of the current operating system. If you use binFile nothing is changed.
Now it can be that line ending characters are in binary data which would be converted. That would be the end of your binary data, it becomes useless.

If you had no problem until now using file instead of binFile you were lucky.

For version testing I do e.g.

Code: Select all

If byte 1 of the version > 6 then
to know if I am using LIvecode 7.x.x

@ Klaus Sorry had to add this. I had to read your post repeatedly to get what you mean and a misunderstanding of your comment could have untoward effects...

Kind regards
Bernd

Re: using binfile vs file for arrayencoding save to file

Posted: Tue Jan 13, 2015 2:27 pm
by Klaus
Hi folks,

no, I was not ironic, I was sarcastic! 8)

Sorry, about a possible misunderstanding with the VERSION stuff, maybe I did not understand the problem correctly.


Best

Klaus

Re: using binfile vs file for arrayencoding save to file

Posted: Tue Jan 13, 2015 3:43 pm
by Coffee1633
thanks for all you fast quick input.
that clears that up... for now...