Page 1 of 4

List all Custom Properties in a stack

Posted: Mon Apr 06, 2015 9:26 am
by erikhans08
Did someone once write a handler to list all Custom Properties in a stack and its stack files, buttons, fields, etc.

Re: List all Custom Properties in a stack

Posted: Mon Apr 06, 2015 2:41 pm
by dunbarx
Hi.

There is a native property, "the customProperties", that does this.

Craig Newman

Re: List all Custom Properties in a stack

Posted: Mon Apr 06, 2015 2:55 pm
by FourthWorld
@erikhans08: which property are you looking for?

Re: List all Custom Properties in a stack

Posted: Mon Apr 06, 2015 5:10 pm
by dunbarx
@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

Re: List all Custom Properties in a stack

Posted: Mon Apr 06, 2015 6:02 pm
by FourthWorld
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.

Re: List all Custom Properties in a stack

Posted: Mon Apr 06, 2015 8:13 pm
by TerryL
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

Re: List all Custom Properties in a stack

Posted: Tue Apr 07, 2015 9:26 am
by erikhans08
'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.

Re: List all Custom Properties in a stack

Posted: Wed Jul 27, 2022 8:53 pm
by marksmithhfx
dunbarx wrote:
Mon Apr 06, 2015 2:41 pm
Hi.

There is a native property, "the customProperties", that does this.

Craig Newman
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" :wink:

Mark

Re: List all Custom Properties in a stack

Posted: Wed Jul 27, 2022 10:24 pm
by dunbarx
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

Re: List all Custom Properties in a stack

Posted: Thu Jul 28, 2022 8:42 am
by Klaus
Or use the "tree view" widget to visualize "the customkeys" array!

Re: List all Custom Properties in a stack

Posted: Fri Jul 29, 2022 4:24 am
by bobcole
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
CustomPropertiesExample.livecode.zip
(1.49 KiB) Downloaded 75 times

Re: List all Custom Properties in a stack

Posted: Fri Jul 29, 2022 5:30 pm
by jiml
Bob,

Thanks

Jim Lambert

Re: List all Custom Properties in a stack

Posted: Sat Jul 30, 2022 6:37 pm
by marksmithhfx
dunbarx wrote:
Wed Jul 27, 2022 10:24 pm
Mark.

This property is in array form. You will see nothing if you just ask for it.
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

Re: List all Custom Properties in a stack

Posted: Sat Jul 30, 2022 6:39 pm
by marksmithhfx
Klaus wrote:
Thu Jul 28, 2022 8:42 am
Or use the "tree view" widget to visualize "the customkeys" array!
Haven't got there yet, but sounds interesting. Tomorrows exercise :D

Re: List all Custom Properties in a stack

Posted: Sat Jul 30, 2022 7:46 pm
by FourthWorld
marksmithhfx wrote:
Sat Jul 30, 2022 6:39 pm
Klaus wrote:
Thu Jul 28, 2022 8:42 am
Or use the "tree view" widget to visualize "the customkeys" array!
Haven't got there yet, but sounds interesting. Tomorrows exercise :D
It was built for exactly that purpose. Super easy to use.