A problem with this prefers script...

charles61 cszasz at mac.com
Wed Jul 7 13:35:29 EDT 2010


I am trying to set up a preference file. I have two stacks - a splash stack
and an app stack. The Prefs stack is a substack of the app stack and is not
a separate stack I trying to use the url and binfile with specialfolder to
set up my preference file in the appropriate place for windows
(specialFolderPath(26) ) and mac (specialFolderPath("preferences")).

I am getting an error message for  

put arrayDecode(tPrefs) into tPrefs

in the following script for the Prefs stack when I select Preferences from
the menu of my app during the run mode:

on preOpenStack
   set the loc of me to the loc of stack "S504"
   loadPrefs
end preOpenStack

on closeStack
   saveprefs
end closeStack

on loadPrefs pFilename
   local tPrefs
   
   IF the platform is "MacOS"   ----> I added this to retrieve the prefs
file for both Mac and Windows
   then 
      put url ("binfile:" & specialFolderPath("preferences")) into tPrefs 
   end if
   
   IF the platform is "win32" 
   then 
      put url ("binfile:" & specialFolderPath(26)) into tPrefs  
   end if
   
   put arrayDecode(tPrefs) into tPrefs ----------------> This is being being
flagged when I select Prefs from the menu in the run mode.
   
   -- Fill in all prefs data...
   put tPrefs["Myschool"] into field "MySchool"
   put tPrefs["Myschool"] into field "school system" of card "referral" of
stack "S504"
   put tPrefs["agent"] into field "agent"
   put tPrefs["agent"] into field "agent" of card "letter" of stack "S504"
   put tPrefs["agent"] into field "agent" of card "adult letter" of stack
"S504"
   put tPrefs["contact"] into field "contact"
   put tPrefs["contact"] into field "contact" of card "letter" of stack
"S504"
   put tPrefs["contact"] into field "contact" of card "adult letter" of
stack "S S504"
   put tPrefs["email"] into field "email"
   put tPrefs["email"] into field "email" of card "letter" of stack "S504"
   put tPrefs["email"] into field "email" of card "adult letter" of stack
"S504"
end loadPrefs

on savePrefs pFilename
   local tPrefs
   
   --fill in all of my data
   put field "mySchool" into tPrefs["school name"]
   put field "agent" into tPrefs["agent"]
   put field "contact" into tPrefs["contact"]
   put field "email" into tPrefs["email"]
   
   IF the platform is "MacOS" 
   then 
      put arrayEncode(tPrefs) into url ("binfile:" &
specialFolderPath("preferences")) --> I added this to save the prefs file
for Mac
   end if
   
   IF the platform is "win32" 
   then 
      put arrayEncode(tPrefs) into url ("binfile:" & specialFolderPath(26))
---> I added this to save the prefs file for Windows
   end if
   
end savePrefs

I would appreciate any help I can get on this script! This is my first
endeavor with using an array, binfile and specialFolderpath!

-- 
View this message in context: http://runtime-revolution.278305.n4.nabble.com/A-problem-with-this-prefers-script-tp2281250p2281250.html
Sent from the Revolution - User mailing list archive at Nabble.com.



More information about the use-livecode mailing list