ordered Array
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: ordered Array
An array with sequential numerical keys starting at 1 will emit the values in numeric key order when looping using a “repeat for each element tVal of tArray” construct.
-
- Posts: 30
- Joined: Mon Apr 13, 2020 8:46 am
Re: ordered Array
I ended up using padded numbers (because sort works on strings, not number)
an alternative is to put multi dimension array where the first element in the array is the order
really ... I am amazed sometimes to the lack of 'standard' programming tools.
I know this is used to teach kids or newbies - and it's a shame that most of the world uses different methods to accomplish things - and this teaches workaround / non standards methods, shame
an alternative is to put multi dimension array where the first element in the array is the order
really ... I am amazed sometimes to the lack of 'standard' programming tools.
I know this is used to teach kids or newbies - and it's a shame that most of the world uses different methods to accomplish things - and this teaches workaround / non standards methods, shame
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: ordered Array
Not needed, as I noted yesterday: while the sort command's default is alphabetical, you can use the "numeric" specifier to get a numeric sort. And, should you ever need it down the road, you can also sort by date and/or time with the "datetime" specifier.foosmaster wrote: ↑Tue Apr 14, 2020 4:34 pmI ended up using padded numbers (because sort works on strings, not number)
an alternative is to put multi dimension array where the first element in the array is the order
The language reference includes these and other options:
https://livecode.com/resources/api/#liv ... _container
Is it? I suppose everyone's a newbie in the beginning of anything. But I was introduced to LiveCode when I was hired to port a Mac software product to become multiplatform, and nearly all my LiveCode work since has been delivering commercial products or making in-house solutions businesses ranging in size from 5 to 50,000 employees.really ... I am amazed sometimes to the lack of 'standard' programming tools.
I know this is used to teach kids or newbies
If one language did everything best the TIOBE Index would have only one entry, and we wouldn't see new languages coming out nearly every year.and it's a shame that most of the world uses different methods to accomplish things - and this teaches workaround / non standards methods, shame

Modern programming is increasingly polyglot by nature because we have such a vast range of languages, and each brings something valuable to the table.
LiveCode's sweet spot is multi-platform GUIs, where it's a strong productivity contender for mobile and nearly unmatched on the desktop. Most other languages treat GUIs as an afterthought, requiring glue routines to coerce them into languages that are fine in general but have no internal support for GUIs.
LiveCode is in a very small class of languages that have GUI elements as an integral part of the language, facilitating iterative design and development workflows where the user interface is recognized as important, given equal footing with underlying business logic.
And under the hood, you'll find the occasional gem like what we affectionately call "chunk expressions", an almost natural-language-like ease of manipulating text, which makes up so much of programming, without ever having to set up things like nested indexOf counters.
The combination of features that distinguish LiveCode do indeed make it uncommon, but for the projects where it's a good fit you may find equally uncommon productivity.
As with any other language, there are some things I'd like to see added to LiveCode, and indexed arrays are among them.
But truth be told the number of times using an associate array wasn't good enough to get the jobs I'm asked to do done is small, countable on one hand.
In fact, where indexed arrays tend to be most powerful is in things best done outside of a scripting language anyway, like image filters. For tasks like that where performance is critical beyond what we'd expect from any scripting language, LC has among its extensibility options a means of hooking in compiled C code, known in LC parlance as "externals".
Still, there is some algorithmic benefit to even smaller tasks with indexed arrays, and since they were added to LC's Builder language not long ago, I suspect they'll find their way into LC Script as time permits.
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
-
- Posts: 30
- Joined: Mon Apr 13, 2020 8:46 am
Re: ordered Array
I meant no disrespect, every language has its benefits, I guess my main annoyance comes from the fact my son went to a course where they chose LiveCode as the environment (hence my insistning on LC for his first 2-3 projects) but his understanding of actual programming concept is little to none existing, most of it due to the teacher's fault and not LC (I had to explain what variable means, an array, function, etc. etc.)
my main trouble comes right now from the IDE performance which is VERY poor, not only save, sometimes opening a card, or switching to debug mode - more often than not, I have to wait over 5 seconds for the IDE to unfreeze, this is crazy, and the scale of the program is REALLY small (2 screens, a few hundrands lines of code, 800K all in all for the livecode binary)
so really, unless the linux experience is REALLY different (and I am half curious to install it on my Ubuntu box and test it there) - I Really can't understand how you'd use it nowaday for a real life scenario when you get lightening speed IDEs
my main trouble comes right now from the IDE performance which is VERY poor, not only save, sometimes opening a card, or switching to debug mode - more often than not, I have to wait over 5 seconds for the IDE to unfreeze, this is crazy, and the scale of the program is REALLY small (2 screens, a few hundrands lines of code, 800K all in all for the livecode binary)
so really, unless the linux experience is REALLY different (and I am half curious to install it on my Ubuntu box and test it there) - I Really can't understand how you'd use it nowaday for a real life scenario when you get lightening speed IDEs
Re: ordered Array
I know this will be of little consolation as I am typing it, but the IDE is slowly coming back to where it used to be in terms of speed when working in it.
For instance, you can (still) download the vers. 7.1.4 of the IDE from here, and run it. See if that more closely fits your idea of the speed an IDE should have. Currently, the IDE is going through a pretty large re-write, and hasn't completely settled. Once it is completed, I suspect it will be as fast as it needs to be, obviously it isn't there yet.
I don't think 7.x is going to help your son out, though, language wise it is probably sufficient, but it is from the 'pre-widgets' era of Lc.
For instance, you can (still) download the vers. 7.1.4 of the IDE from here, and run it. See if that more closely fits your idea of the speed an IDE should have. Currently, the IDE is going through a pretty large re-write, and hasn't completely settled. Once it is completed, I suspect it will be as fast as it needs to be, obviously it isn't there yet.
I don't think 7.x is going to help your son out, though, language wise it is probably sufficient, but it is from the 'pre-widgets' era of Lc.

Re: ordered Array
I see none of the delays you speak of (LC v.9.5.1, Mac 10.13).IDE performance which is VERY poor, not only save, sometimes opening a card, or switching to debug mode - more often than not, I have to wait over 5 seconds for the IDE to unfreeze, this is crazy, and the scale of the program is REALLY small (2 screens, a few hundrands lines of code, 800K all in all for the livecode binary)
I know people like Bogs are comfortable working in older versions.
But I would not tolerate the multi-second delays that seem to plague you, and would have also languished in earlier builds, since I do not use much of the fancy new stuff after v.7.
Anyway, something is wrong with your setup. Can you tell us exactly what your environment is?
Craig
Re: ordered Array
...and if Bogs had been awake when he posted, he might have suggested something completely different, such as turning off a few of the options in the SE that have previously dragged things to a near stand still


-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: ordered Array
Feel free to pass my email address on to the teacher: ambassador AT fourthworld.comfoosmaster wrote: ↑Thu Apr 16, 2020 11:43 amI meant no disrespect, every language has its benefits, I guess my main annoyance comes from the fact my son went to a course where they chose LiveCode as the environment (hence my insistning on LC for his first 2-3 projects) but his understanding of actual programming concept is little to none existing, most of it due to the teacher's fault and not LC (I had to explain what variable means, an array, function, etc. etc.)
I may be able to provide additional teaching materials to make the coursework done with LiveCode more empowering for both students and teacher alike.
I've discovered what appears to be a redundancy in the Script Editor's redraw, esp. noticeable when debugging. I'm working to pin that down so I can submit a fix.my main trouble comes right now from the IDE performance which is VERY poor, not only save, sometimes opening a card, or switching to debug mode - more often than not, I have to wait over 5 seconds for the IDE to unfreeze, this is crazy, and the scale of the program is REALLY small (2 screens, a few hundrands lines of code, 800K all in all for the livecode binary)
As you find specific recipes for slowdowns that are especially impactful please post them here, they'll be helpful for the ongoiing optimization efforts of the core team and the community.
I spend most of my time on Ubuntu with an increasing amount of development time on Windows over the last year. LC is definitely faster overall on Ubuntu. Some things like debugging still show the effects of the aforementioned layout redundancy, but overall I find LC quite snappy on Ubuntu.so really, unless the linux experience is REALLY different (and I am half curious to install it on my Ubuntu box and test it there) - I Really can't understand how you'd use it nowaday for a real life scenario when you get lightening speed IDEs
That said, I often find it snappy on Windows too. But when it slows down, it slows down hard. I haven't yet pinned down the specific differences causing the slowdown, and reviewing the bug reports for that it seems the core team has also had difficulty finding consistently reproducible recipes. So anything you find along those lines will be helpful - thanks in advance.
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: ordered Array
Richard. I only use a Mac. Have you heard of these sorts of slowdowns there?That said, I often find it snappy on Windows too. But when it slows down, it slows down hard.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: ordered Array
Not as noticeably, but if my hunch about the Script Editor's redraw redundancy is correct you should find a few things there a little snappier.
But that may be a while. Right now I'm working on a new script editor...
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
-
- Posts: 30
- Joined: Mon Apr 13, 2020 8:46 am
Re: ordered Array
debugging on windows is pretty much impossible, just stepping takes abuot 5-10 seconds for no REAL actions (e.g. stepping into a function, over defining local) nothing that does any real computing, so I suspect something about debugging is just.
another thing I've noticed is that I am using long polling via load url ... which on timeout creates another request
if that long poll is on, I can't really do any development with LC, save takes forever stepping takes forever.
another bad experience is if I step into a function, I can't step out, it just continues (unless I'd place a breakpoint in the enclosing function)
example:
maybe I can rollback to 7.5, seems like a good idea ...
how hard would it be to save a stack from 9.5 back to 7 ?
my son would kill me if he had to reacreate the interace again
another thing I've noticed is that I am using long polling via load url ... which on timeout creates another request
if that long poll is on, I can't really do any development with LC, save takes forever stepping takes forever.
another bad experience is if I step into a function, I can't step out, it just continues (unless I'd place a breakpoint in the enclosing function)
example:
Code: Select all
function a
local tLocal, tB
put 1 into tLocal # place breakPoint here
put b() into tB # step into this
put 2 into tLocal # unless I put a breakpoint here - I can't reach it if I stepped into the fomer statement
return 1
end a
function b
local tTemp
put 1 into tTemp
return 1
end b
maybe I can rollback to 7.5, seems like a good idea ...
how hard would it be to save a stack from 9.5 back to 7 ?
my son would kill me if he had to reacreate the interace again
Re: ordered Array
foosmaster, saving backwards in and of itself is not very hard, you simply click 'Save As...', and in the dialog hit the dropdown and choose how far back you want to go.
However, I should warn you this comes with some caveats, as I mentioned above. For one thing, no widgets pre - 8.x, and even between 8 and 9 the structure of widgets I believe changed.
There are also some language changes / functions that were added after 7, so this is not something done lightly. IF you decide to try it, when your in the 'save as ' dialog, by all that is holy save the stack modifying the name (both internally and externally). This will prevent you from, among other things, mixing the stacks up or getting errors about it already being in memory.
Again, before you decide to go down this drastic route with the kids stack, please consider what Craig, Richard and I said about finding out *why* it is so slow. Things that are helpful to know are things like:
your OS
what do you have running in the background (taskbar/system tray)
etc etc. You may even wind up taking a look at running processes, at some point, but I strongly suggest trying to at least find out.
Good luck.
However, I should warn you this comes with some caveats, as I mentioned above. For one thing, no widgets pre - 8.x, and even between 8 and 9 the structure of widgets I believe changed.
There are also some language changes / functions that were added after 7, so this is not something done lightly. IF you decide to try it, when your in the 'save as ' dialog, by all that is holy save the stack modifying the name (both internally and externally). This will prevent you from, among other things, mixing the stacks up or getting errors about it already being in memory.
Again, before you decide to go down this drastic route with the kids stack, please consider what Craig, Richard and I said about finding out *why* it is so slow. Things that are helpful to know are things like:
your OS
what do you have running in the background (taskbar/system tray)
etc etc. You may even wind up taking a look at running processes, at some point, but I strongly suggest trying to at least find out.
Good luck.

Re: ordered Array
Given that there is such a problem pinning down recipes and the team are working without much specific direction to kill known bugs, but rather optimise situations that occur without consistent patterns, they are doing really well to improve performance of the IDE and specifically the Script Editor. Version 9.x improvements have included fixes for memory leaks and random behaviours, but they are not yet back at the performance of pre-unicode refacxxxxxx versions. Any recipe for problems that can be reproduced should be reported. My difficulty has been being able to create a recipe.FourthWorld wrote: ↑Thu Apr 16, 2020 4:24 pmThat said, I often find it snappy on Windows too. But when it slows down, it slows down hard. I haven't yet pinned down the specific differences causing the slowdown, and reviewing the bug reports for that it seems the core team has also had difficulty finding consistently reproducible recipes. So anything you find along those lines will be helpful - thanks in advance.
Richard's comments here to me are especially encouraging that the team are aware of issues, and actively trying to deal with them, even without a bug number that can be itemised and checked off.
Best tips so far for improving IDE performance include:
Closing the Project Browser wherever possible. Never try to move and adjust multiple objects with the Project Browser open.
Turn off Script Editor "helpers" (code completion etc)
Add LiveCode to exclusions list for antivirus and (for Testing ONLY) turn off Windows Defender temporarily.
Re: ordered Array
All of that.
But that "several seconds" is the issue tells me this is not a LC problem. Such slowness would have caused a riot long ago. All my debugging work is virtually instantaneous, regardless of the size of the stack or the length of the script.
Also;
Something outside of LC, assuming the program itself is not corrupt, is causing all this.
I would hate to lose even one user because of some environmental snafu, mistakenly blamed on LC.
Craig
But that "several seconds" is the issue tells me this is not a LC problem. Such slowness would have caused a riot long ago. All my debugging work is virtually instantaneous, regardless of the size of the stack or the length of the script.
Also;
Something is awry. Are you sure you know how to use the "step into", "step over" and "step out" gadgets? And how to set either hard or soft breakpoints? I have never encountered any of the travails that you describe.another bad experience is if I step into a function, I can't step out, it just continues (unless I'd place a breakpoint in the enclosing function)
Something outside of LC, assuming the program itself is not corrupt, is causing all this.
I would hate to lose even one user because of some environmental snafu, mistakenly blamed on LC.
Craig
-
- Posts: 30
- Joined: Mon Apr 13, 2020 8:46 am
Re: ordered Array
my CPU load is very low, it's around 25%, livecode doesn't create a CPU spike at all, it just hangs.
I don't know how or why I'd need to setup debugging stepping into/out functions, I've been developing for over 30 years, and never experienced a strange situation like this, I don't mind uploading my project for anyone to test it, it's just 2 visible stacks and 2 SOS
btw, the SOS have a card in them which I wasn't able to delete - or at least the project browser shows that I have that.
I'll try to remove the variable checking and see.
btw, I opened it on ubuntu and it DOES work a lot faster, but I can't shift my son to work on an OS he doesn't know at all
I don't know how or why I'd need to setup debugging stepping into/out functions, I've been developing for over 30 years, and never experienced a strange situation like this, I don't mind uploading my project for anyone to test it, it's just 2 visible stacks and 2 SOS
btw, the SOS have a card in them which I wasn't able to delete - or at least the project browser shows that I have that.
I'll try to remove the variable checking and see.
btw, I opened it on ubuntu and it DOES work a lot faster, but I can't shift my son to work on an OS he doesn't know at all
