Page 1 of 1

Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 1:25 am
by Mag
Hi all!

I would like to store a custom property on a stack file created in Preferences folder.

I'm trying to use this:

Code: Select all

put specialFolderPath("preferences") & slash & "myAppPrefs" into myAppPrefsPath
set the cTest of stack myAppPrefsPath to "test"
Unfortunately the property is not created...

Re: Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 1:40 am
by sturgis
You might confirm that the file is there by adjusting your code to this..

Code: Select all

if there is a file myAppPrefsPath then
set the cTest of stack myAppPrefsPath to "test"
else
answer information "Can't find the file"
end if
At least this will help eliminate a pathing issue as the problem.

Re: Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 2:47 pm
by Mag
OK, tested. No errors but the property is not there. Maybe I have to open the stack before to set the property, or I have to create the property before to try to set it? Or I have to use ".rev" as file extension?

Re: Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 3:10 pm
by sturgis
Nope, extension shouldn't matter, shouldn't have to open the stack first (I don't believe).

If you:

1) use your curent code to set the property
then
2) use the same path varable to open the stack and look at it with the property inspector does the property show? Meaning is there a chance that there is something amis with your pathing so that you're setting the property in one location and trying to get it using a slightly different path? Not likely, but gotta ask.

As for creating the property before you set it, don't think so. The act of setting it should create it.

Also might check the contents if "it" and "the result" right after you "set the ctest of stack myAppPrefsPath" to check for any errors in the result.

Other than that, not sure.

What OS is this on? Was wondering if there was a permissions problem. If there is, you should be able to see the error in the result right after you try to set the property.

Maybe post the stack for testing?

Re: Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 8:41 pm
by Mag
Hi sturgis,

tryied what you suggest (to open the stack using the same path), and it opened correctly and this time with the property in place.

So maybe the problem could be that after set the property I have to open the stack in the same script to "consolidate" the property?

(OS X 10.8.2 - LC 5.5.4)

Re: Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 8:48 pm
by jacque
Sturgis is right on all counts. The property is there, you don't have to do anything else. I use your exact code in Zygodact and it works fine. Referencing the property will create it if it doesn't already exist, and you don't have to specifically open the stack to do it. File extensions don't matter either.

I don't know how you are checking the value after setting it, but I do it by setting the property as you do now, and then getting it again. It doesn't have to be in the same handler or script:

Code: Select all

on setPref
    put specialFolderPath("preferences") & slash & "myAppPrefs" into myAppPrefsPath
    set the cTest of stack myAppPrefsPath to "test"
end setPref

on getPref
    put specialFolderPath("preferences") & slash & "myAppPrefs" into myAppPrefsPath
    put the cTest of stack myAppPrefsPath
end getPref

Re: Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 9:10 pm
by Mag
Thank you so much sturgis and jacque, I will do more test to learn what I'm doing wrong then, and if I discover some more, I will post here.

BTW, I noticed that there are some sort of conventions to give a name to containers, for example, to start a custom property with "c", a temp variable with "t" and so on. Is there a place where I can find info about this?

Re: Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 9:16 pm
by sturgis
Might check out Richard Gaskins page at http://www.fourthworld.com/embassy/arti ... style.html has lots of interesting thoughts including naming conventions.

Though of course when it comes right down to it, what works for you is what works for you.

Re: Store a custom property on a stack file created in Prefs

Posted: Sun Mar 31, 2013 9:19 pm
by Mag
Thank you!