List all Custom Properties in a stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 87
- Joined: Wed Mar 25, 2015 2:01 am
List all Custom Properties in a stack
Did someone once write a handler to list all Custom Properties in a stack and its stack files, buttons, fields, etc.
-
- VIP Livecode Opensource Backer
- Posts: 9656
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: List all Custom Properties in a stack
Hi.
There is a native property, "the customProperties", that does this.
Craig Newman
There is a native property, "the customProperties", that does this.
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: List all Custom Properties in a stack
@erikhans08: which property are you looking for?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9656
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: List all Custom Properties in a stack
@Richard, he wants custom properties.
@ Erik. Are you able to write your own handler that lists all the custom properties for any or all controls in a stack file? If you can, then, as Richard implied, you could extract any particular one of interest. But without that list, there is no way of knowing what those properties are, since you made and named them at some time in the past.
Craig
@ Erik. Are you able to write your own handler that lists all the custom properties for any or all controls in a stack file? If you can, then, as Richard implied, you could extract any particular one of interest. But without that list, there is no way of knowing what those properties are, since you made and named them at some time in the past.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: List all Custom Properties in a stack
Thank you, Craig, but I think his thread title made that clear; pardon the brevity of my question.
I asked because I used to spend a lot of time making all sorts of stack reporting tools which produced text listing of all sorts of stuff. But over time I realized I never actually used that output because it was disconnected from the objects they were reporting - to take any action meant I still had to find the object in question and edit it.
To find the best solution here will depend on what's truly needed, so it would be helpful to find out what will be done with the custom property once found.
I asked because I used to spend a lot of time making all sorts of stack reporting tools which produced text listing of all sorts of stuff. But over time I realized I never actually used that output because it was disconnected from the objects they were reporting - to take any action meant I still had to find the object in question and edit it.
To find the best solution here will depend on what's truly needed, so it would be helpful to find out what will be done with the custom property once found.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: List all Custom Properties in a stack
You could use the customKeys property, which returns a line list of all custom props for an object. Another simpler solution is to look in each object's properties inspector under custom properties if there are only a few objects in the stack. Terry
Code: Select all
local AllCustomProps
put the short name of this stack &cr& the customKeys of this stack &cr after AllCustomProps
repeat with i = 1 to number(cds in this stack)
put the short name of cd i &cr& the customKeys of cd i after AllCustomProps
repeat with j = 1 to number(btns in this cd) --btns, flds, imgs, graphics...
put the short name of btn j &cr& the customKeys of btn j &cr after AllCustomProps
end repeat
--...
end repeat
Beginner Lab (LiveCode tutorial) and StarterKit (my public stacks)
https://tlittle72.neocities.org/info.html
https://tlittle72.neocities.org/info.html
-
- Posts: 87
- Joined: Wed Mar 25, 2015 2:01 am
Re: List all Custom Properties in a stack
'The customkeys of my mainstack returned all of my custom properties, exactly as in the Stack Property Inspector.
My custom properties are all in my mainstack and I set them within a handler called from Message Box when I first open the mainstack.
The names of the custom properties are all preceded by a "u", as in uHeight, following The Gaskin Guidelines.
These 2 also show up although not declared by me:
Selection Description = false
revstack = false
So I can get all of my custom properties from Stack Property Inspector or Message Box.
I just like to be able to see them all at once.
My custom properties are all in my mainstack and I set them within a handler called from Message Box when I first open the mainstack.
The names of the custom properties are all preceded by a "u", as in uHeight, following The Gaskin Guidelines.
These 2 also show up although not declared by me:
Selection Description = false
revstack = false
So I can get all of my custom properties from Stack Property Inspector or Message Box.
I just like to be able to see them all at once.
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: List all Custom Properties in a stack
When I tried listing the "customProperties" of this (my) stack I got nothing. When I changed it to customKeys or userProperties I got a list of all of the custom properties of my stack.
Have filed this under "The Joys of Syntax"
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 9656
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: List all Custom Properties in a stack
Mark.
This property is in array form. You will see nothing if you just ask for it.
The SE breaks out arrays in its variable pane if you set a breakPoint after getting that property. Alternatively, you can take the output and use the "combine" command to change the array variable into an ordinary variable
Craig
This property is in array form. You will see nothing if you just ask for it.
The SE breaks out arrays in its variable pane if you set a breakPoint after getting that property. Alternatively, you can take the output and use the "combine" command to change the array variable into an ordinary variable
Craig
Re: List all Custom Properties in a stack
Or use the "tree view" widget to visualize "the customkeys" array!
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Tue Feb 23, 2010 10:53 pm
- Location: Saint Louis, Missouri USA
Re: List all Custom Properties in a stack
Here is a example stack with some custom properties added to the stack's built-in "customKeys" property (a.k.a, a set of properties). Also, I added two additional custom property sets.
The customKeys set is built-in so I just had to add two test properties and values in the stack inspector.
The two additional property sets were also created and properties added via the stack inspector.
The stack has one button and one output field.
The button gets the new custom keys and puts them in the field along with their values.
Then the button gets the two additional property sets (using the "customPropertySets" property), assembles their keys and values, and puts the results into the output field.
This has been a good exercise. I provide the stack in case anyone else wants to see this little example.
Bob
The customKeys set is built-in so I just had to add two test properties and values in the stack inspector.
The two additional property sets were also created and properties added via the stack inspector.
The stack has one button and one output field.
The button gets the new custom keys and puts them in the field along with their values.
Then the button gets the two additional property sets (using the "customPropertySets" property), assembles their keys and values, and puts the results into the output field.
This has been a good exercise. I provide the stack in case anyone else wants to see this little example.
Bob
Re: List all Custom Properties in a stack
Bob,
Thanks
Jim Lambert
Thanks
Jim Lambert
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: List all Custom Properties in a stack
Craig,
Good point. If you use "customKeys" or its synonym "userProperties" you get a list of the keys of the array. To get the keys and their values I typically use a function I store in my stack script called displayArrayData(pArray, pIndent) which unpacks and displays the elements of any array. I guess the take away, having reviewed the docs, is that customProperties are an array, and the name of each custom property is a key in the array. But, since I've been using "customProperties" (correctly) for describing this data structure for so long, it's hard for me to remember that typically all I am looking for is the keys.
The stack Bob Cole put together also looks very useful in terms of explaining the nuances of these data structures. Thanks Bob!!
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: List all Custom Properties in a stack
Haven't got there yet, but sounds interesting. Tomorrows exercise
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: List all Custom Properties in a stack
It was built for exactly that purpose. Super easy to use.marksmithhfx wrote: ↑Sat Jul 30, 2022 6:39 pmHaven't got there yet, but sounds interesting. Tomorrows exercise
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn