ordered Array

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

bwmilby
Posts: 462
Joined: Wed Jun 07, 2017 5:37 am
Contact:

Re: ordered Array

Post by bwmilby » Mon Apr 13, 2020 11:22 pm

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.

foosmaster
Posts: 30
Joined: Mon Apr 13, 2020 8:46 am

Re: ordered Array

Post by foosmaster » Tue Apr 14, 2020 4:34 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: ordered Array

Post by FourthWorld » Tue Apr 14, 2020 6:55 pm

foosmaster wrote:
Tue Apr 14, 2020 4:34 pm
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
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.

The language reference includes these and other options:
https://livecode.com/resources/api/#liv ... _container
really ... I am amazed sometimes to the lack of 'standard' programming tools.
I know this is used to teach kids or newbies
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.
and it's a shame that most of the world uses different methods to accomplish things - and this teaches workaround / non standards methods, shame
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. :)

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

foosmaster
Posts: 30
Joined: Mon Apr 13, 2020 8:46 am

Re: ordered Array

Post by foosmaster » Thu Apr 16, 2020 11:43 am

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

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

Re: ordered Array

Post by bogs » Thu Apr 16, 2020 12:31 pm

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.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: ordered Array

Post by dunbarx » Thu Apr 16, 2020 3:00 pm

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 see none of the delays you speak of (LC v.9.5.1, Mac 10.13).

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

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

Re: ordered Array

Post by bogs » Thu Apr 16, 2020 3:35 pm

dunbarx wrote:
Thu Apr 16, 2020 3:00 pm
I know people like Bogs are comfortable working in older versions.
...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 Image such as the options highlighted in green below...
aPic_LcOptions.png
Errors ?! My code never has...zzzzZZZZZZZtttttt....
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: ordered Array

Post by FourthWorld » Thu Apr 16, 2020 4:24 pm

foosmaster wrote:
Thu Apr 16, 2020 11:43 am
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.)
Feel free to pass my email address on to the teacher: ambassador AT fourthworld.com

I may be able to provide additional teaching materials to make the coursework done with LiveCode more empowering for both students and teacher alike.
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)
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.

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.
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
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.

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: ordered Array

Post by dunbarx » Thu Apr 16, 2020 5:12 pm

That said, I often find it snappy on Windows too. But when it slows down, it slows down hard.
Richard. I only use a Mac. Have you heard of these sorts of slowdowns there?

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: ordered Array

Post by FourthWorld » Thu Apr 16, 2020 5:34 pm

dunbarx wrote:
Thu Apr 16, 2020 5:12 pm
That said, I often find it snappy on Windows too. But when it slows down, it slows down hard.
Richard. I only use a Mac. Have you heard of these sorts of slowdowns there?
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

foosmaster
Posts: 30
Joined: Mon Apr 13, 2020 8:46 am

Re: ordered Array

Post by foosmaster » Thu Apr 16, 2020 9:32 pm

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:

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

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

Re: ordered Array

Post by bogs » Thu Apr 16, 2020 10:17 pm

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.
Image

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Re: ordered Array

Post by SparkOut » Thu Apr 16, 2020 10:23 pm

FourthWorld wrote:
Thu Apr 16, 2020 4:24 pm
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.
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.
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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: ordered Array

Post by dunbarx » Fri Apr 17, 2020 12:12 am

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;
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 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.

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

foosmaster
Posts: 30
Joined: Mon Apr 13, 2020 8:46 am

Re: ordered Array

Post by foosmaster » Fri Apr 17, 2020 5:16 am

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 :(

Post Reply