List all Custom Properties in a stack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

erikhans08
Posts: 87
Joined: Wed Mar 25, 2015 2:01 am

List all Custom Properties in a stack

Post by erikhans08 » Mon Apr 06, 2015 9:26 am

Did someone once write a handler to list all Custom Properties in a stack and its stack files, buttons, fields, etc.

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » Mon Apr 06, 2015 2:41 pm

Hi.

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

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
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

Post by FourthWorld » Mon Apr 06, 2015 2:55 pm

@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

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » Mon Apr 06, 2015 5:10 pm

@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

FourthWorld
VIP Livecode Opensource Backer
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

Post by FourthWorld » Mon Apr 06, 2015 6:02 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

TerryL
Posts: 78
Joined: Sat Nov 23, 2013 8:57 pm

Re: List all Custom Properties in a stack

Post by TerryL » Mon Apr 06, 2015 8:13 pm

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

erikhans08
Posts: 87
Joined: Wed Mar 25, 2015 2:01 am

Re: List all Custom Properties in a stack

Post by erikhans08 » Tue Apr 07, 2015 9:26 am

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

marksmithhfx
VIP Livecode Opensource Backer
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

Post by marksmithhfx » Wed Jul 27, 2022 8:53 pm

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » Wed Jul 27, 2022 10:24 pm

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

Klaus
Posts: 13823
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: List all Custom Properties in a stack

Post by Klaus » Thu Jul 28, 2022 8:42 am

Or use the "tree view" widget to visualize "the customkeys" array!

bobcole
VIP Livecode Opensource Backer
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

Post by bobcole » Fri Jul 29, 2022 4:24 am

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

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: List all Custom Properties in a stack

Post by jiml » Fri Jul 29, 2022 5:30 pm

Bob,

Thanks

Jim Lambert

marksmithhfx
VIP Livecode Opensource Backer
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

Post by marksmithhfx » Sat Jul 30, 2022 6:37 pm

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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
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

Post by marksmithhfx » 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
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

FourthWorld
VIP Livecode Opensource Backer
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

Post by FourthWorld » Sat Jul 30, 2022 7:46 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”