Store a custom property on a stack file created in Prefs

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Store a custom property on a stack file created in Prefs

Post by Mag » Sun Mar 31, 2013 1:25 am

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...

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

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

Post by sturgis » Sun Mar 31, 2013 1:40 am

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.

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

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

Post by Mag » Sun Mar 31, 2013 2:47 pm

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?

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

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

Post by sturgis » Sun Mar 31, 2013 3:10 pm

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?

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

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

Post by Mag » Sun Mar 31, 2013 8:41 pm

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)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7229
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Sun Mar 31, 2013 8:48 pm

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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

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

Post by Mag » Sun Mar 31, 2013 9:10 pm

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?

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

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

Post by sturgis » Sun Mar 31, 2013 9:16 pm

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.

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

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

Post by Mag » Sun Mar 31, 2013 9:19 pm

Thank you!

Post Reply

Return to “Mac OS”