Trouble with CustomPropertySets

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

Post Reply
Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Trouble with CustomPropertySets

Post by Traxgeek » Sat Feb 16, 2013 10:39 am

Hi,

I'm trying to use a CustomPropertySet to store user selected properties for a given object and no matter how I try it I don't see my custom property set appear in the Custom Properties section of my Stack.

This was my final code snippet (I've tried dozens after reading the posts and the tutorials) :

Code: Select all

put "FirstCustomPropertySet" into sCstmPropSet
put "CustomProperty1" into sCstmProp

set the sCstmPropSet[sCstmProp] of this stack to the short system time
My code compiles and runs when invoked (with no errors :?: ) BUT I don't see my newly created FirstCustomPropertySet (or its associated CustomProperty1) in the Custom Properties section of the Stack Property Inspector. Neither can I see it should I look in the 'Set :" section just below the properties that do exist...

I've been on this for a while (still not really 'clicking' with LC yet and constantly finding myself typing in C :? ) Any suggestions please ?

Greatly appreciated.

TIA
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Trouble with CustomPropertySets

Post by Traxgeek » Sat Feb 16, 2013 11:43 am

Aha - finally,

Found a way around this :) Might not be the best way and it does concern me that I still don't understand my previous code error :? BUT...

remove single line, double barelled approach

Code: Select all

set the sCstmPropSet[sCstmProp] ...
and replace it with two lines of code

Code: Select all

set the custompropertyset of this stack to sCstmPropSet
set the sCstmProp ...
and all is well :D

Doesn't explain why my last attempt didn't work but...

I had also mis-read / not fully read the tutorial :oops: ... I thought the

Code: Select all

'set the custompropertyset of... ' 
was used purely to READ any custom properties within the stated set... I hadn't appreciated it also worked for setting them...

Sorry for my bletherings above/previous... (might turn out useful for some other newbie in the future tho').

Happy weekend...
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trouble with CustomPropertySets

Post by Klaus » Sat Feb 16, 2013 12:37 pm

Hi Trax,

just teseted this and it may be a bug!

This does indeed work programmatically, but you do not see the cp set in the inspector
...
put "FirstCustomPropertySet" into sCstmPropSet
put "CustomProperty1" into sCstmProp
set the sCstmPropSet[sCstmProp] of this stack to the short system time
...

This does also work programmatically and you SEE the cp set in the inspector:
...
set the FirstCustomPropertySet["CustomProperty1"] of this stack to the short system time
...
Hmmm... :)

Good that you 2-step solution does work for you.


Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Trouble with CustomPropertySets

Post by Traxgeek » Sat Feb 16, 2013 1:43 pm

Thanks Klaus,

Thought it was just me !

I have another one though if I may ?

put the customproperties of this stack into sCPF --Insert a breakpoint after this line and hover over sCPF - The Custom Properties are displayed in (what looks like) a cr delimited 'list'
set the linedelimiter to cr --Change the cr to tab or whatever...
put the number of lines in sCPF into N --results in N = 0 (elements, items etc all result in N = 0 when there is patently data in sCPF

the above code, no matter how I modify it (I've been 'at it' for many hours...) results in N = 0 :x
however,

put the customkeys of this stack into sCPF
set the linedelimiter to cr
--Change the cr to tab or whatever...
put the number of lines in sCPF into N --result in N = a useful number ( <>0 ) :)

My requirement is to be able to generically and dynamically create, set, empty and delete Custom Properties as required... and it's turned into a more-than-8-hour adventure...

Any ideas as to why I need to use the CustomKeys and not CustomProperties property to achieve this. I could 'justify' this if the CustomProperties were part of a CustomPropertySet but they're not (in this case). Again, apart from trying to understand, this may be of use to someone else in the future - sure would have saved me hours of frustration...

What did I miss please ?

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trouble with CustomPropertySets

Post by Klaus » Sat Feb 16, 2013 1:51 pm

Hi Traxgeek,
Traxgeek wrote:...
Any ideas as to why I need to use the CustomKeys and not CustomProperties property to achieve this.
Sorry, no idea, and I really don't care actually!
I take the language "as is", don't have the time to question it 8)
Traxgeek wrote:I could 'justify' this if the CustomProperties were part of a CustomPropertySet but they're not (in this case).
"Justify"? Come on!
If you need to justify the Livecode syntax, please do this in your free time :D
Sorry, but this rather "philosophical" approach is not my "cup of tea" 8)

Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Trouble with CustomPropertySets

Post by Traxgeek » Sat Feb 16, 2013 2:53 pm

Sorry Klaus,

I maybe wrote that badly.. it's just the example I had looked at all used CustomProperties and not CustomKeys...

1- I'm not trying to be awkward - just to understand and learn 8)
2- I'm a complete Noobie to LiveCode (d'oh!) and I take the code examples as 'gospel' / 'as read' / absolute...
3- I come from many years from VS, C and others; with this history LC is hard to get to grips with and it would simply be great to understand the difference(s) between CustomProperties and CustomKeys, maybe they're interchangeable :oops: Oops ! - I didn't and still don't know ! Certainly, in my case I could have saved many hours of frustration if I knew more... :D
4- Poor use of the word 'justify' I guess - apologies

Thanks a million anyways.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trouble with CustomPropertySets

Post by Klaus » Sat Feb 16, 2013 3:14 pm

Hi Traxgeek,

looks like I need to apologize for not knowing the difference between customkeys and customporperties! 8)
Damn, I still learn something new in Livecode almost every day :D

OK, here we go:
"the customkeys of stack/card etc." is a CR delimited list of all the names of all keys of a custom property(set)
-> can be directly put into a field for display

"the customproperties of stack/card etc." is an ARRAY! with "the customkeys" as the keynames and their value as content.
-> Arrays cannot be display in a field, they need to be converted to a string before.

Thanks for forcing me to look up these terms in the dictionary :D

Have a nice weekend!


Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Trouble with CustomPropertySets

Post by Traxgeek » Sat Feb 16, 2013 3:36 pm

Hi Klaus,
-> Arrays cannot be display in a field, they need to be converted to a string before.

Thanks for forcing me to look up these terms in the dictionary :D
Well I'll be... I was sure I had read the dictionary entries CAREFULLY. I'm wrong - my apologies :oops: . It really isn't my intention to get someone else (in this case you !) to 'do my dirty work' for me - even if it is much easier :wink: ... It's amazing that even now I miss so much no matter how many times I THINK I've Read The Flippin Manual... apologies :oops: and a million thanks :oops: . I had struggled for a good few hours (and more) with split and combine, itemdelimiter and linedelimiter, 'put the number of lines' and 'put the number of elements' etc. with respect to CustomPRIOPERTIES when, in fact, I SHOULD have been concentrating on CustomKEYS... :oops:

Interesting to note though that there have a bee a few instances I've come across already where code is accepted and run (no bugs) but fails to do ANYTHING (wrt having code do something unintended (happens all the time :D ) - it's rare to have it accepted and then do nothing)

Moral : RTFM again and again and more CAREFULLY...

Have a great weekend. Like I said, a million thanks.

Weather here is beautiful - should be on the beach !!! 8)

Regards.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Trouble with CustomPropertySets

Post by Klaus » Sat Feb 16, 2013 4:03 pm

Hi Traxgeek,

as I said, no need to apologize or be embarrassed!
I am working with Livecode (its grandfather Metacard actually) since 1999 and still learn something new almost every day!
So I am always pleased about hints that help me fill these small gaps :D


Best

Klaus (from cold and rainy germany, ENVY :D )
Where are you located?

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Trouble with CustomPropertySets

Post by Traxgeek » Sat Feb 16, 2013 4:51 pm

The beautiful and (today, at least) sunny west coast of France - just south of the Ile de Ouessant. My office looks out over a deserted white sandy beach & sand dunes some 300 mtr away... it is beautiful, great for walking, yachting and surfing - in fact, next stop westwards is the States.
If you're ever in the area you'd be welcome - and I could return your helpfulness with a a beer or cider !

Have a great weekend - I hope the weather cheers up for you !
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Post Reply