No new customProperties?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

No new customProperties?

Post by dunbarx » Fri Apr 13, 2018 9:12 pm

OK, I give up.

On a new card, make two buttons. In button 1, create a custom property, like "XYZ" and set its contents to "ABC"

Now

Code: Select all

set the customProperties of btn 2 to the customProperties of btn 1
Nothing changes in btn 2. No new custom properties.

The original custom property set is already in array form, though the property inspector resolves it. So I cannot see why it does not just appear in btn 2.

Craig Newman
Last edited by dunbarx on Fri Apr 13, 2018 10:08 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: No new customProperties?

Post by dunbarx » Fri Apr 13, 2018 9:47 pm

So I guess I answered my own question.

The default custom property set in any object is named "customKeys". Or so I thought. Please correct me, but that is not a real custom property set, even though it holds one or more real custom properties.

When I create my own new custom property set, and then "copy" that to another control, all works fine.

All my LC life I have never used more than one custom property set, assuming that the default was as good as any. Only when I wanted to transfer that set to another control did I learn I cannot.

In a new control, if I create one or more custom properties, am I correct is assuming that they live in no custom property set, but just hang around as loose custom properties? That they have to be explicitly placed in a new set, because the default "set" named "customKeys" is not really a set?

Craig Newman

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: No new customProperties?

Post by bogs » Sat Apr 14, 2018 4:34 am

I'm not sure thats my take on it, but it doesn't mean your wrong either. From the current dictionary -
Brian's dictionary
Use the customKeys property to find out what custom properties an object has, and to create or delete custom properties.

The customKeys lists the names of properties in the object's current . If the object has more than one custom property set, you must switch to the desired property set before checking the customKeys.
From Mc -
Selection_003.png
Mc entry for customKeys
I found both of these to be pretty skimpy, so I went to my mvp of dictionaries to look :D

In Rev 2.2x, there is of course a lot more depth to the information on custom properties (and pretty much everything else), so much so that it is too much to put here, another reason I am working on liberating the help system from this version of the IDE. In part, though, it says "
Using Custom Properties
A custom property is a property that you define. You can create as many custom properties for an object as you want, and put any kind of data into them (even binary data). You can even store a file in a custom property.

Use a custom property when you want to:
* associate data with a specific object
* save the data with the object in the stack file
* access the data quickly

Creating a custom property
You create a custom property by setting the new property to a value. If you set a custom property that doesn't exist, Revolution automatically creates the custom property and sets it to the requested value.

Important! Each object can have its own custom propertiess, and custom properties are not shared between objects. Creating a custom property for one object does not create it for other objects.

Important! Custom property names beginning with "rev" are reserved for Revolution's own custom properties. Naming a custom property with a reserved name may produce unexpected results when working in the development environment.

Like built-in properties, custom properties are sources of value, so you can get the value of a custom property by using it in an expression. The property's value is substituted for the property reference when the statement is executed. For example, if the card's "lastCall" custom property is "Today", the example statement above puts the string "Today" into the "Date" field.

The customProperties property:
The customProperties of an object consists of all the object's custom properties, in array form: each element of the array is a single custom property.

[The part that pertains to your question starts here]
You can set (or get) all the custom properties of an object at once using the customProperties property. The following example copies the custom properties of one button to another button:

set the customProperties of button 2 \
to the customProperties of button 1

Because the customProperties is an array, you can put it into a variable. To selectively change custom properties, it is sometimes convenient to move custom properties to a variable, change the elements of that variable, and then copy the variable to the customProperties of another object (or the original object). The following example gets the custom properties of a button, changes one custom property (called "MyProp"), then copies all the custom properties to a different button:

put the customProperties of button 1 into theCustomProps
-- ...creates an array variable called "theCustomProps"
-- Now we change one element of that variable:
put "123" into theCustomProps["MyProp"]
-- ...and set another button's properties to the copy:
set the customProperties of button 2 to theCustomProps

Nonexistent custom properties:
Custom properties that don't exist evaluate to empty.

For example, if the current card doesn't have a custom property called "astCall", the following statement empties the field:

put the astCall of this card into field "Date" -- empty

Note: Referring to a nonexistent custom property does not cause a script error. This means that if you misspell a custom property name in a handler, you won't get an error message, so you might not notice the problem right away.

[The part that pertains 'customKeys' starts here]
Finding out whether a custom property exists:
The customKeys property of an object lists the object's custom properties, one per line:

put the customKeys of button 1 into field "Custom Props"

To find out whether a custom property for an object exists, you check whether it's listed in the object's customKeys. The following statement checks whether a player has a custom property called "doTellAll":

if "doTellAll" is among the lines of the customKeys \
of player "My Player" then...

You can also look in the Custom Properties pane of the object's property inspector, which lists the custom properties.
There was a lot more, but i think that was the most important parts. If you still have a copy of rev 2.2 or so vintage kicking around, crack it open and use the "search documentation'' in the road map, probably more information than you will want to know at 4 links.
Image

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: No new customProperties?

Post by jameshale » Sun Apr 15, 2018 12:02 am

Not wanting to rain on anyone’s parad but all this talk of the ealier versions of the docs being more complete seems to ignore the LiveCode Guide. This is available via the guide tab in the dictionary or as a complete pdf compilation if you select “user guide” via the help menu.
In any case this discussion, and more, on custom properties is in the guide section “Programming a User Interface”.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: No new customProperties?

Post by dunbarx » Sun Apr 15, 2018 1:08 am

If one asks for the "customPropertySets" in a new control, you only get "cRevGeneral", even though there seems to be a default set called "customKeys".

There it is, right in the pulldown with an adjacent label field "Sets:".

There isn't such a set. It is a phantom, like the old "mouseUp" handler in a new button.

I just did not know that, and wasted a lot o time trying to figure out why nothing I did worked.

It is no shook to me that one can have custom properties that need not belong to a set. It was only shocking that the "set" LC seemed to provide did not exist.

Live and learn.

Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: No new customProperties?

Post by bogs » Sun Apr 15, 2018 4:23 am

jameshale wrote:
Sun Apr 15, 2018 12:02 am
This is available via the guide tab in the dictionary ...
In any case this discussion, and more, on custom properties is in the guide section “Programming a User Interface”.
You'll have to pardon my bias and ignorance, James, the Lc9 dictionary (unlike previous ones) pops up very slowly in a browser window on my system (linux, but not one of the 'supported' versions), so it is a little hard for me to discuss the virtues of the "guides" part of it with any relevance.

I do suppose I could have flipped through the 300+ pages of the .pdf version to see what I could find, but for some reason that was an...oh... unappealing option to me I guess you'd say.

I know, I know, how lazy can I get right? :wink:

Craig, I'm glad you know what you know however you know it :mrgreen:
Image

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: No new customProperties?

Post by jameshale » Sun Apr 15, 2018 4:50 am

Ah, opportunity for shameless plug.

There is a linux reader (Zeal) for the Dash formatted documentation sets.
http://forums.livecode.com/viewtopic.ph ... 5&start=15

The discussion here points you to a way of creating your own, or accessing the docset I upload.
Mark Wieder shared how he got the linux reader “Zeal” to load the user contributed docset here:
http://forums.livecode.com/viewtopic.ph ... 15#p161737

The docset contains all the guides as well as the dictionary.
It was created using the latest LC9.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: No new customProperties?

Post by bogs » Sun Apr 15, 2018 5:04 am

Well, while I appreciate your efforts and, I believe, said so in other threads, I'm not in anything newer than 6.x enough to have to work at it so much. I'm actually in Mc the most, Lc 6.5.2 2nd most, and Lc 2.x after that. The only time I ever launch anything newer is to help someone else or test something for someone else.

I still think your project has a lot of merit, even if I don't use it myself.
Image

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: No new customProperties?

Post by jameshale » Sun Apr 15, 2018 5:33 am

Well the beauty of the current documentation is that it includes all the stuff in earlier versions and clearly states if an item was introduced later (i.e. version 2, 4, 7, 8 or 9)

As for the PDF version of the user guide. Again I am on a Mac and don't know what Linux users have at their disposal, but at least on the Mac, Apple's preview lets me search the PDF. I would have thought that Linux has a similarly enabled PDF reader. No need to go through page by page at all.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: No new customProperties?

Post by bogs » Sun Apr 15, 2018 7:42 am

See, I think that is where you and I are going to divide a bit. I don't think the dictionary has comments anymore (I believe introduced circa 3.x? 2.x?) which were incredibly helpful. As for pdf docs, there are programs I could use I'm sure that would allow me to search it. Firefox, for instance, if I hit Open file and browsed to the location (where ever they put it, I lost track of it some versions ago), however it doesn't open in Firefox by default on linux, that is something I would have to really want to do (i.e. go find out where it is).

As for
the beauty of the current documentation is that it includes all the stuff in earlier versions and clearly states if an item was introduced later (i.e. version 2, 4, 7, 8 or 9)
That has been the format since 2.x. for the dictionary, but "documentation" is a pretty broad descriptor. Again, due to my own ignorance about the current state of the documentation from my lack of experience with same, I haven't any relevant thing to compare it to.

I don't think it is either as fast or easy to find what you are looking for in the current model as the much MUCH older model, but that is an opinion, not a fact. From what I saw of the guide back when I was playing in 8.x, I think it was a vast improvement over the .pdf.

I did find a number of things in the help folders I never knew existed before, but I count that as another knock on the way things went in the help section.

But that is really a discussion for another place and time, now that we've run rampant all over Craig's post, heh, i'll make my apologies and exit.

*Edit - Just to give you an idea of what the dictionary currently looks like when you click on it in a (non supported) linux distro, this should give you some idea. Nothing is resizable either.
StepOsTesters [Running] - Oracle VM VirtualBox_003.png
Lc Dictionary
When I go to look something up when I do use Lc9, I actually use Brian's dictionary, or Max's wiki, or Bernd's excellent tinyDictionary.
Image

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

Re: No new customProperties?

Post by jacque » Sun Apr 15, 2018 3:49 pm

dunbarx wrote:
Sun Apr 15, 2018 1:08 am
If one asks for the "customPropertySets" in a new control, you only get "cRevGeneral", even though there seems to be a default set called "customKeys".
Back in the old days we didn't have custom property sets. After they were introduced, custom sets had names and the default set name is empty. So unless you specifically set the default set, you get the empty one. And because its name is empty, it doesn't show up in the property sets list, but it is there.

"CustomKeys" isn't the name of a set, it's the list of keys in the current set.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: No new customProperties?

Post by bogs » Sun Apr 15, 2018 4:10 pm

jacque wrote:
Sun Apr 15, 2018 3:49 pm
Back in the old days we didn't have custom property sets.
Curious if you remember (approximately) when they did get introduced, Jacque? I know they existed in Mc 2.5 (before it went Oss). I'll be looking through my copy of Hypercard later today...but you could save me a bunch of time hahah.
Image

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: No new customProperties?

Post by bwmilby » Mon Apr 16, 2018 12:47 am

dunbarx wrote:
Fri Apr 13, 2018 9:12 pm
On a new card, make two buttons. In button 1, create a custom property, like "XYZ" and set its contents to "ABC"

Code: Select all

set the customProperties of btn 2 to the customProperties of btn 1
Nothing changes in btn 2. No new custom properties.
I can't reproduce this on LC9/Mac Sierra. I created a new stack with buttons B1 and B2. Here is the script of a third button:

Code: Select all

on mouseUp
   set the customProperties of btn "B2" to the customProperties of btn "B1"
end mouseUp
This results in B2 having the same "XYZ" as B1. I also added a nested key in the PI and it copied as well. Could this be an object reference issue?
bogs wrote:
Sun Apr 15, 2018 7:42 am
*Edit - Just to give you an idea of what the dictionary currently looks like when you click on it in a (non supported) linux distro, this should give you some idea. Nothing is resizable either.
StepOsTesters [Running] - Oracle VM VirtualBox_003.png
What you're seeing there is due to the media breaks/CSS. The browser window is too narrow to show the page properly (on Mac/Win, the dictionary window is coded to not allow it to be resized too small). That is something that I'd like to fix, but it is probably going to take a bit of redesign of the structure of the page (HTML/CSS). And if doing that, it would probably make sense to evaluate the move to the latest version of Bootstrap (4.x - which may make it easier). You should be able to adjust the split between terms and definition, but it isn't as big of a deal now since it scrolls out of the way.

Also, in 9.0 it will open this way even on Ubuntu.

Thanks,
Brian
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: No new customProperties?

Post by bogs » Mon Apr 16, 2018 3:01 am

That is interesting to know Brian. The screen res in that picture is 1024x768 (close to the size of my laptops screen), and as you see in that picture, the browser window is taking up almost all of it. I wonder how large a monitor you should have to have to be able to see the dictionary & what you are working on?
Image

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: No new customProperties?

Post by bwmilby » Mon Apr 16, 2018 3:53 am

1024 works, but the dock can’t be on the side. The IDE is set for 992 minimum width. If you slide the browser behind it you can make it full width and see it a little better.

And I see on Linux that the resize bar isn’t showing. Curious that other images are also missing.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

Post Reply

Return to “Talking LiveCode”