Page 2 of 4
Re: Custom properties?
Posted: Wed Dec 02, 2015 11:22 pm
by adventuresofgreg
I was wrong... This does work:
set the pTestX["1"] of this stack to "hi"
so... put max(the pTest["1"] of this stack) should also work. Thanks!
Re: Custom properties?
Posted: Thu Dec 03, 2015 1:24 am
by dunbarx
Greg.
Sure. Anything that can go into a variable can go into a custom property. Like arrays or images.
Craig
Re: Custom properties?
Posted: Thu Dec 03, 2015 1:28 am
by adventuresofgreg
but.. how would I convert this particular reference to a global?
put item 1 of myline & "," & item 5 of myline & return after SQarray[ALLname]
With SQarray being the global
Because, with properties, you must "set", can't "put after" ?
set the SQarrayProp[ALLname] of this stack to AFTER item 1 of myline ??
Re: Custom properties?
Posted: Thu Dec 03, 2015 3:27 am
by dunbarx
Hi.
Just takes a second to get used to the different syntax.
Code: Select all
set the XYZ of this stack to the XYZ of this stack & return & someNewData --appends a new line (after?) to the property
More words than putting data into or after a variable, but nonetheless a simple and straightforward construction.
But remember the original issue. A custom property is a global repository of data, accessible from anywhere within LC, but local to the stack it lives in. If you clone a stack with a custom property from stack "A" to stack"B", that property will be copied over. But then you can modify the contents of each independently.
Globals are common to all stacks in the current session. Change it, and it changes everywhere.
I am saying that the extra words are a non-issue compared with the perfect functionality offered.
Craig
Re: Custom properties?
Posted: Thu Dec 03, 2015 1:45 pm
by Klaus
Hi Greg,
adventuresofgreg wrote:...
set the pTestX["1"] of this stack to "hi"
...
this will create a custom property SET named "pTest" with a key named "1" with content "hi" in your stack
But using NUMBERS as NAMES (be it for keys or objects) is not a good idea in Livecode!
Best
Klaus
Re: Custom properties?
Posted: Thu Dec 03, 2015 2:29 pm
by adventuresofgreg
dunbarx wrote:Hi.
Just takes a second to get used to the different syntax.
Code: Select all
set the XYZ of this stack to the XYZ of this stack & return & someNewData --appends a new line (after?) to the property
More words than putting data into or after a variable, but nonetheless a simple and straightforward construction.
But remember the original issue. A custom property is a global repository of data, accessible from anywhere within LC, but local to the stack it lives in. If you clone a stack with a custom property from stack "A" to stack"B", that property will be copied over. But then you can modify the contents of each independently.
Globals are common to all stacks in the current session. Change it, and it changes everywhere.
I am saying that the extra words are a non-issue compared with the perfect functionality offered.
Craig
Thanks a lot Craig. I'll make these changes and run some timed tests and I'll report back. Currently, it seems like there is some kind of cache in the LC engine where it will take some time to load the custom property into the local variable the first time it is called. After that initial load, it runs faster.
Re: Custom properties?
Posted: Thu Dec 03, 2015 5:06 pm
by adventuresofgreg
ClipArtGuy wrote:Code: Select all
clone stack "Greg"
set the UniqueDataArray of stack "Greg copy" to DataArray
this should give your copy stack a custom property called "UniqueDataArray" which should contain your array
so clipartguy, just out of curiosity, how are you the "clipartguy" ?

PEM me
greg@justgreg.com
Re: Custom properties?
Posted: Thu Dec 03, 2015 7:02 pm
by adventuresofgreg
hmm... still having some problems avoiding dumping that custom property into a variable. Can you think of a way to do this with the property rather than a variable?
Code: Select all
repeat for each line myline in MetricsArray[Sname]
end repeat
I could dump the pMetricsArray of this stack into a VAR, then split the var into an array, or repeat for each line myline as per example, but then I would have to stick it back into the custom property thereby defeating the purpose of reducing these costly data moves.
Re: Custom properties?
Posted: Thu Dec 03, 2015 10:13 pm
by dunbarx
An array does not have "lines". Try it. in a button
Code: Select all
on mouseUp
repeat with y = 1 to 4
put y into MetricsArray[y]
end repeat
breakpoint
repeat for each line myline in MetricsArray[Sname]
put sname
end repeat
end mouseUp
Step through the handler. You can see the array in the debugger, but that is because LC likes you. What do you know, there are no lines in the array at all. If you had
you would get empty.
Normal LC processes required normal LC variables. You can use arrays all you like, but you cannot manipulate them them with "in the clear" means. You need either array methods, or use the "combine" command to get them into ordinary variable form.
Craig
Re: Custom properties?
Posted: Thu Dec 03, 2015 10:45 pm
by adventuresofgreg
My arrays have lines
Re: Custom properties?
Posted: Fri Dec 04, 2015 4:10 am
by dunbarx
My arrays have lines
Well, not really, and in any case they are not accessible in the clear. Did you try my handler above? Arrays are associations of keys and elements. They have no "ordinary" structure, like lines delimited by returns.
Craig
Re: Custom properties?
Posted: Fri Dec 04, 2015 2:28 pm
by adventuresofgreg
Arrays with lines:
Code: Select all
Repeat for each key mykey in MyArray
Repeat for each line myline in MyArray[MyKey]
Repeat for each item myitem in myline
End repeat
End repeat
End repeat
Re: Custom properties?
Posted: Fri Dec 04, 2015 2:33 pm
by Klaus
Hey, the CONTENT of array keys does not count!

Re: Custom properties?
Posted: Fri Dec 04, 2015 2:37 pm
by adventuresofgreg
I'm concerned with speed. When the user moves the sliders, the graphs and metrics are updated in real time. So, there is a lot of sorting through many very large arrays that are retrieved from a SQL DB. I wrote my own graphing functions also (no ChartsEngine).
Re: Custom properties?
Posted: Fri Dec 04, 2015 3:45 pm
by dunbarx
Your app looks very professional.
So without getting into a discussion that likely is just about terminology and semantics, your code snippet deconstructs the array via its keys, as Klaus alluded to. The "combine" command deconstructs an array as well, bringing it into the clear, as I like to say.
I only care that you understand that if you make an array, and then do something like:
That you do not think anything is amiss when you get empty as a result.
Craig