using binfile vs file for arrayencoding save to file

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Coffee1633
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 219
Joined: Mon Dec 05, 2011 5:35 pm

using binfile vs file for arrayencoding save to file

Post by Coffee1633 » Tue Jan 13, 2015 11:25 am

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?

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: using binfile vs file for arrayencoding save to file

Post by Klaus » Tue Jan 13, 2015 1:44 pm

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: using binfile vs file for arrayencoding save to file

Post by bn » Tue Jan 13, 2015 2:08 pm

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: using binfile vs file for arrayencoding save to file

Post by Klaus » Tue Jan 13, 2015 2:27 pm

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

Coffee1633
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 219
Joined: Mon Dec 05, 2011 5:35 pm

Re: using binfile vs file for arrayencoding save to file

Post by Coffee1633 » Tue Jan 13, 2015 3:43 pm

thanks for all you fast quick input.
that clears that up... for now...

Post Reply