Custom properties?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: Custom properties?
This interesting Craig. Let me ask then, what would be the most efficient way of storing and retrieving data in an array.
Raw data:
a return delimited list, each mine containing tab delimited items, with the last item being a very large comma delimited group of 'sub' items. And this list might be 10's of thousands of lines long.
And, there are a few dozen of these lists.
So what I do, is store each list in its own array: masterfata[symbol]
Then when retrieving it, I repeat for each line, repeat for each item and thrn perform some function on that last item of hundreds of comma delimited items.
I could treat each line as a sub array, but calling the repeat for myline/myitem seems just as fast from tests.
Raw data:
a return delimited list, each mine containing tab delimited items, with the last item being a very large comma delimited group of 'sub' items. And this list might be 10's of thousands of lines long.
And, there are a few dozen of these lists.
So what I do, is store each list in its own array: masterfata[symbol]
Then when retrieving it, I repeat for each line, repeat for each item and thrn perform some function on that last item of hundreds of comma delimited items.
I could treat each line as a sub array, but calling the repeat for myline/myitem seems just as fast from tests.
Re: Custom properties?
Hmmm.
I guess we are just not communicating well, since you are obviously running this just fine. To make sure, run this in a button:
You get empty for the line, because you cannot access a "line" in an array by ordinary means. So when you say that
Craig
I guess we are just not communicating well, since you are obviously running this just fine. To make sure, run this in a button:
Code: Select all
on mouseUp
repeat with y = 1 to 10
put y * 10 into myArray[y]
end repeat
answer "Line 5 of the array is:" && line 5 of myArray -- empty
answer "Key 5 of the array contains:" && myArray[5] --50
end mouseUp
you must mean that you are somehow transforming the array data into clear data. With the "combine" command, perhaps? Because you cannot use the sort of gadgetry I used in the first "answer" part of the above code directly on an array.Then when retrieving it, I repeat for each line...
Craig
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: Custom properties?
But you didn't put a return key char into your array. Therefore there would be no lines.
Put x*10 & return after myarray[x]
Then you can
Put line 10 of myarray[x]
??
Put x*10 & return after myarray[x]
Then you can
Put line 10 of myarray[x]
??
Re: Custom properties?
Greg.
If I run this:
I get empty in the first "answer". If I step through, I see the same array exploded in the variable watcher. The return does nothing, though I was excited that I might discover something entirely new (for me) about arrays
BUT:
Hmmm.
Craig
If I run this:
Code: Select all
on mouseUp
repeat with y = 1 to 10
put y * 10 & return after myArray[y]
end repeat
answer "Line 5 of the array is:" && line 5 of myArray -- empty
answer "Key 5 of the array contains:" && myArray[5] --50
end mouseUp
BUT:
Code: Select all
on mouseUp
repeat with y = 1 to 10
put y * 10 & return & return after myArray[y]
end repeat
answer "Line 5 of the array is:" && line 5 of myArray -- empty
answer "Key 5 of the array contains:" && myArray[5] --50
answer the number of lines of myArray[5]
end mouseUp
Craig
-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: Custom properties?
Craig. I'm travelling at the moment and can't go through your code. But you can put any character into an element of an array. Return, tab, comma. An entire book if you want. And then refer to line x of mybook[thisbook]
Re: Custom properties?
Greg.
I know. If you add two returns to an element of an array, and then extract it, you will get two lines.
That was a teaser.I was (am) still trying to figure out how your arrays have lines. But rereading your last post, you imply that you have indeed extracted the elements of your array. That was all I ever asked, whether you used, say the "combine" command to put your array data "in the clear". You never said...
Craig
I know. If you add two returns to an element of an array, and then extract it, you will get two lines.
That was a teaser.I was (am) still trying to figure out how your arrays have lines. But rereading your last post, you imply that you have indeed extracted the elements of your array. That was all I ever asked, whether you used, say the "combine" command to put your array data "in the clear". You never said...
Craig
Re: Custom properties?
As I wrote a couple of days before, Greg has lines in the CONTENT of his array keys and that does not count!
But obviously noone was listening, the story of my life...
But obviously noone was listening, the story of my life...

Re: Custom properties?
Klaus.
I am the one who writes things, and then they are passed over, being re-suggested downPost by others. Not you. It is the nature of modern quick reading. Many join a thread at the end, unless they have been involved all the way through, and start at that point.
I saw your post when it came through. You and I are on the same page.
Anyway,I think this thread has reached a dead end. Greg knows what he is doing; I just wanted to clarify the ideas. Many posts concern just what I am on about, that an array cannot be "seen" without it being changed into "ordinary" form.
Craig
I am the one who writes things, and then they are passed over, being re-suggested downPost by others. Not you. It is the nature of modern quick reading. Many join a thread at the end, unless they have been involved all the way through, and start at that point.
I saw your post when it came through. You and I are on the same page.
Anyway,I think this thread has reached a dead end. Greg knows what he is doing; I just wanted to clarify the ideas. Many posts concern just what I am on about, that an array cannot be "seen" without it being changed into "ordinary" form.
Craig

-
- Posts: 349
- Joined: Tue Oct 28, 2008 1:23 am
- Contact:
Re: Custom properties?
I think I was getting confused over terms. But my original problem was resolved with your solution Craig - to use a custom property and I thank you for that.
The drawback to using a custom property over a global variable, is that you can't "process" the data in the custom property without extracting it first. And this extraction (or, combine, or decompose if it's an array) takes time. Whereas, you can manipulate and process data within an array in a global without ever having to decompose it.
When using the globals, my script was processing the data in about 60 to 100 ms which is fast enough to allow the user to change settings by sliding a scroll bar and watch the analysis in near real time. When loading the globals into and out of the custom property, that additional step was ADDING 1000 to 2000 ms which is too slow.
I did find a fix to this problem. I changed the global arrays to local, then check to see if the local array is empty in which case, I load it from a custom property. Since this only needs to be done once, the 2000 ms time required to haul the data from the property into a local is acceptable.
This move from globals to locals with a custom property load, now allows me to create multiple clones of the stack, and I can choose what data to share among all open stacks, and which data to keep as local to the stacks.
The drawback to using a custom property over a global variable, is that you can't "process" the data in the custom property without extracting it first. And this extraction (or, combine, or decompose if it's an array) takes time. Whereas, you can manipulate and process data within an array in a global without ever having to decompose it.
When using the globals, my script was processing the data in about 60 to 100 ms which is fast enough to allow the user to change settings by sliding a scroll bar and watch the analysis in near real time. When loading the globals into and out of the custom property, that additional step was ADDING 1000 to 2000 ms which is too slow.
I did find a fix to this problem. I changed the global arrays to local, then check to see if the local array is empty in which case, I load it from a custom property. Since this only needs to be done once, the 2000 ms time required to haul the data from the property into a local is acceptable.
This move from globals to locals with a custom property load, now allows me to create multiple clones of the stack, and I can choose what data to share among all open stacks, and which data to keep as local to the stacks.
Re: Custom properties?
Greg.
Right on.
Craig
Right on.
Craig
Re: Custom properties?
I have a question about custom properties and would appreciate some light.
Custom properties survive across sessions while global variables would have to be written out to a file to be saved, right?
How would this work in the context of an app, which would need to be updated?
Wouldn't the current state of a custom property be lost when a new stack file replaces the old?
To prevent this, the custom property would have to be written out to a file every time (just like a global), wouldn't it?
Thanks,
Sri
Custom properties survive across sessions while global variables would have to be written out to a file to be saved, right?
How would this work in the context of an app, which would need to be updated?
Wouldn't the current state of a custom property be lost when a new stack file replaces the old?
To prevent this, the custom property would have to be written out to a file every time (just like a global), wouldn't it?
Thanks,
Sri
Re: Custom properties?
By the way,
Interesting website, Greg!
Sri
Interesting website, Greg!
Sri
Re: Custom properties?
Sri
from the disk to globals or custom properties
Best regards
Jean-Marc
Yes. Globals and customproperties should be written out to a file and imported at preopenstack or what you want.To prevent this, the custom property would have to be written out to a file every time (just like a global), wouldn't it?
When you update your app you change standalone only and it Import fileHow would this work in the context of an app, which would need to be updated?
from the disk to globals or custom properties
Best regards
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 10057
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Custom properties?
Arrays can be made into persistent forms in two ways: serialized with arrayEncode, or stored in a stack file.adventuresofgreg wrote:...what would be the most efficient way of storing and retrieving data in an array.
ArrayEncode/arrayDecode is reasonably efficient (much more so than storing in intermediary formats like JSON or XML), but when the array size is mall enough (in my tests, < 100 MB or so) you may find creating stack files for storing arrays represented within them as customproperty sets and custom properties to be the fastest method of loading array data from a cold boot.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Custom properties?
Thanks Jean-Marc!jmburnod wrote:.....customproperties should be written out to a file ........
Sri