A real problem with Prefs!!

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

A real problem with Prefs!!

charles61
I successful finished testing my app within the IDE. I created a standalone and then launched it on Windows XP. I got the following error message from the Bug Report as an email:

Object: stack 'C:/Documents and Settings/All Users/Application Data/MyProduct/S504.rev'
Line Num: 65
Hint: loadPrefs

I dismissed the error report. I went ahead and ran my program. I opened the prefs and created a pref file. The next time I launched my program, I did not get the error report above. So, apparently the program is looking for a nonexistent Prefs file and when it doesn't find it I get the error report.

Here is my stack script:

on preOpenStack
   loadPrefs
end preOpenStack

on loadPrefs pFilename
   local tPrefs
   --   put url ("binfile:" & pFilename) into tPrefs
   IF the platform is "win32"
   then
      put url ("binfile:" & specialFolderPath(26) & "/" & "504_prefs") into tPrefs
   end if
   
   put arrayDecode(tPrefs) into tPrefs
   
   put tPrefs["school"] into field "mySchool" of card id 1002 of stack "prefs"
   put tPrefs["school"] into field "school" of card "referral" of stack "S504"
   put tPrefs["school"] into field "site" of card "adult" of stack "S504"
   
   put tPrefs["contact"] into field "contact" of card id 1002 of stack "prefs"
   put tPrefs["contact"] into field "contact" of card "letter" of stack "S504"
   put tPrefs["contact"] into field "contact" of card "adult letter" of stack "S504"
   
end loadPrefs

I thought that the code:
put url ("binfile:" & specialFolderPath(26) & "/" & "504_prefs") into tPrefs

created a folder named 504_Prefs

What am I missing here?
Reply | Threaded
Open this post in threaded view
|

Re: A real problem with Prefs!!

mwieder
charles61-

> I thought that the code:
> put url ("binfile:" & specialFolderPath(26) & "/" & "504_prefs") into tPrefs

> created a folder named 504_Prefs

> What am I missing here?

No, that reads the prefs file.
To create the file you need

put tPrefs into url ("binfile:" & specialFolderPath(26) & "/" & "504_prefs")

--
-Mark Wieder
 [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: A real problem with Prefs!!

charles61
Hi Mark!

I had that code in the actual Prefs stack but not in my app stack script. If I put the following:

put tPrefs into url ("binfile:" & specialFolderPath(26) & "/" & "504_prefs")

before loadPrefs in app stack script I should be okay?

Charles Szasz
[hidden email]




On Aug 2, 2010, at 9:02 PM, Mark Wieder [via Runtime Revolution] wrote:

> put tPrefs into url ("binfile:" & specialFolderPath(26) & "/" & "504_prefs")

Reply | Threaded
Open this post in threaded view
|

Re: A real problem with Prefs!!

mwieder
charles61-

Monday, August 2, 2010, 6:07:30 PM, you wrote:


> Hi Mark!

> I had that code in the actual Prefs stack but not in my app stack script. If I put the following:

> put tPrefs into url ("binfile:" & specialFolderPath(26) & "/" & "504_prefs")

> before loadPrefs in app stack script I should be okay?

Beats me. I'm not sure what you're trying to do... is there anything
in tPrefs at the time? If not, why are you creating a blank file and
then trying to load it? Wouldn't you be better off trying something
like

on loadPrefs pFilename
  if there is a file (specialFolderPath(26) & "/" & "504_prefs") then
  ...and continue from there?

--
-Mark Wieder
 [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: A real problem with Prefs!!

charles61
Mark,

Thanks for your suggestion. Here is what I am trying to do. My app has a preferences for the user to complete. It includes the name of the user, telephone number and e-mail address that are used on a couple of cards as part of a document that is later printed out. When the app is first launched, the preferences are empty, waiting to be filled by the user. I will try your suggestion! Again thanks for your time!
Reply | Threaded
Open this post in threaded view
|

Re: A real problem with Prefs!!

charles61
In reply to this post by mwieder
Hi Mark,

I tried your suggestion and it works on both my windows and mac apps!!

Here is my revised stack script of my app stack:

on preOpenStack
   set the loc of this stack to the screenloc
   loadPrefs
end preOpenStack

on loadPrefs pFilename
   local tPrefs
   
   --   put url ("binfile:" & pFilename) into tPrefs
   IF the platform is "MacOS" then
      if there is a file (specialFolderPath(26) & "/" & "S504_prefs") then
         put url ("binfile:" & specialFolderPath("preferences") & "/" & "S504_prefs") into tPrefs
         
         put arrayDecode(tPrefs) into tPrefs

         -- now fill in all my data...
         put tPrefs["school"] into field "mySchool" of card id 1002 of stack "prefs"
         put tPrefs["contact"] into field "contact" of card id 1002 of stack "prefs"
         put tPrefs["email"] into field "email" of card id 1002 of stack "prefs"
      end if
   end if
   
   IF the platform is "win32" then
      if there is a file (specialFolderPath(26) & "/" & "S504_prefs") then
         put url ("binfile:" & specialFolderPath(26) & "/" & "S504_prefs") into tPrefs
         
         put arrayDecode(tPrefs) into tPrefs

         -- now fill in all my data...
         put tPrefs["school"] into field "mySchool" of card id 1002 of stack "prefs"
         put tPrefs["contact"] into field "contact" of card id 1002 of stack "prefs"
         put tPrefs["email"] into field "email" of card id 1002 of stack "prefs"
      end if
   end if
   
end loadPrefs

Please feel free to make any additional comments. This is my first app that employs a prefs stack. My experience with this have been frustrating at time but invaluable for future apps. I am posting this code so that it will be helpful to others.
Reply | Threaded
Open this post in threaded view
|

Re: A real problem with Prefs!!

Chipp Walters
Charles, I will sometimes have a getPrefsFolder() function. Something like:

function getPrefsFolder
   get the effective filename of this stack
   set itemDel to "/"
   delete last item of it
   put "/" & "Prefs" after it
   If there is not a folder it then create folder it
   return it
end getPrefsFolder

HTH
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: A real problem with Prefs!!

charles61
Chipp,

Thanks! I will save it and use it in my next project!

Charles Szasz
[hidden email]




On Aug 5, 2010, at 8:53 PM, Chipp Walters [via Runtime Revolution] wrote:

Charles, I will sometimes have a getPrefsFolder() function. Something like:

function getPrefsFolder
   get the effective filename of this stack
   set itemDel to "/"
   delete last item of it
   put "/" & "Prefs" after it
   If there is not a folder it then create folder it
   return it
end getPrefsFolder

HTH
_______________________________________________
use-revolution mailing list
<a href="x-msg://125/user/SendEmail.jtp?type=node&amp;node=2315803&amp;i=0" target="_top" rel="nofollow">[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution



View message @ http://runtime-revolution.278305.n4.nabble.com/A-real-problem-with-Prefs-tp2311179p2315803.html
To unsubscribe from Re: A real problem with Prefs!!, click here.