Problem with arrayDecode

Peter W A Wood peterwawood at gmail.com
Sun Jul 5 09:34:47 EDT 2015


Thanks Alex. That fixed it.

Regards

Peter

> On 5 Jul 2015, at 19:09, Alex Tweedly <alex at tweedly.net> wrote:
> 
> You would need to use  a binary file (e.g. "binfile:temp.txt")  for the result of arrayencode
> (so I might therefore chose  different extension :-)
> 
> Alex.
> 
> 
> On 05/07/2015 09:46, Peter W A Wood wrote:
>> I am having problems with encoding and decoding an array when I save the encoded data to a file and read it back. Here is a simple LiveCode Server script that shows the issue:
>> 
>> 	#coding:utf-8
>> 
>> 	set the outputLineEndings to “lf”					# OS X
>> 	set the outputTextEncoding to “utf8”				# OS X
>> 
>> 	put "data.db" into preferences["database”]
>> 	put arrayEncode(preferences) into URL “file:temp.txt"
>> 	put URL "file:temp.txt" into encodedPrefs
>> 	if encodedPrefs is not empty then
>> 		put arrayDecode(encodedPrefs) into prefs
>> 		put "The decoded data contains:" && prefs["database"] & return
>> 	end if
>> 
>> 	put "data2.db" into preferences["database”]
>> 	put arrayEncode(preferences) into encodedPrefs
>> 	put arrayDecode(encodedPrefs) into prefs
>> 	put "The decoded data contains:" && prefs["database"] & return
>> 
>> This is what the script outputs:
>> 
>> peter$ test/test.lc
>> The decoded data contains:
>> The decoded data contains: data2.db
>> peter$
>> 
>> Any suggestions to what I’m getting wrong or is it a bug?
>> 
>> Regards
>> 
>> Peter
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list