Function called, doesn't answer!

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm

Re: Function called, doesn't answer!

Post by Ormente » Sat Jun 25, 2016 7:32 am

Nice catch Ross... maybe next time you'll realy outsmart the debugger. Keep trying! :wink:

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: Function called, doesn't answer!

Post by RossG » Sun Jun 26, 2016 1:04 am

This is the test stack I did to help me find that bug.

Doesn't do the important bit. Just updates the numbers
generated by the "HowMany30" and "WayBack" functions.

Click the "Go" button then "Add a Number" and if you
are quick you'll see (some) numbers changing.
Attachments
SpinsSinceTest.zip
(10.93 KiB) Downloaded 231 times
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm

Re: Function called, doesn't answer!

Post by Ormente » Sun Jun 26, 2016 10:02 am

Thanks. I had a look.

I tested the culprit loop repeat with x = -1 to -30, and as expected it didn't work.

In fact, repeat with x = A to B have two ways of "not working".
- It could hang for a while if LC did naively increment A until it reach B (=)
- It could return immediatly if LC check that A >= B beforehand

Looks like it's the second one. I learned something. Nice!

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Function called, doesn't answer!

Post by [-hh] » Mon Jun 27, 2016 11:14 am

[Repost. I try to do a better wording.]

Hi Ormente.
In the sense of your explanation:

repeat with x=A to B (meant as x=A up to B)
is, as RossG said, by LC interpreted as
repeat with x=A to B step 1
no matter the values of A and B

repeat with x= A down to B
is by LC interpreted as
repeat with x=A to B step -1
no matter the values of A and B

If we now set our own step-value, this setting gets precendence.
That's why
repeat with i=-1 to -30 step -1
works (counts from -1 down to -30)

[and similarly
repeat with i=1 down to 30 step 1
works (counts from 1 up to 30)]

Hermann
shiftLock happens

Post Reply