put into URL not "putting"

Dave Cragg dcragg at lacscentre.co.uk
Thu May 5 21:27:19 EDT 2005


On 5 May 2005, at 22:52, Derek Bump wrote:

> Dave Cragg wrote:
>> Is preferencesData declared as a global (or local) variable 
>> somewhere? (e.g. at the top of the script.) If not, the data won't 
>> persist and the array will only contain a single element (the one 
>> just added) when you get to the repeat loop?
>
> It's a global that's declared at the beginning of my common library.  
> My intention is to use my common library for preferences so I can get 
> away from the Registry and ease the port to MacOS X.
>
>> You should check "the result" after the Put ... into url line. This 
>> will tell you if an error occurred.
>
> Yeah, the result just returns empty.
>

In that case, I'd check that your script has really changed the data to 
be written to the file.

on setPref prefName,prefData
   put prefData into preferencesData[prefName]
   put the keys of preferencesData into theKeys
   repeat with x=1 to the number of lines in theKeys
     put line x of theKeys & "=" & preferencesData[(line x of theKeys)] 
&cr after newData
   end repeat
   put newdata ## CHECK HERE that the data is what you expect
   put newData into url ("file:Preferences.dat")
end setPref

Also, when you say "every time afterward it will not write anything" do 
you mean the file remains as it was before or that it is empty?

Cheers
Dave



More information about the use-livecode mailing list