repeat with messages

Richard Gaskin ambassador at fourthworld.com
Fri May 16 23:30:48 EDT 2014


Jerry Jensen wrote:

> OK Richard, sorry for the TL;DR. Here is what I was trying to present:
>
> Mark S. presented a line of code:
> repeat with x = 100 down to 0 with messages
>
> I was surprised to see, in a single line of code:
>  repeat ... WITH MESSAGES
> which isn't in the dictionary syntax description for "repeat".
>
> Mark responded:
> The "with messages" clause makes a repeat loop non-blocking.
>
> I tried it - the compiler didn't complain, and it ran. I wondered:
> WHAT DOES THAT DO? UNBLOCK AT EACH LOOP END?
>
> Then I wondered:
> IF ITS LEGAL AND USEFUL, WHY ISN'T IT IN THE DICTIONARY?
>
> Sorry for the confusion. I still wonder. Over to you.
> .Jerry

Thanks for that, Jerry.

I've never seen "with messages" used in a repeat statement before, and 
in my test here it does nothing.

This:

on mouseup
    repeat with x = 1000 down to 0 with messages
       put x into fld 1
    end repeat
end mouseup

...executes on OS X without any visible change to the field until it's 
done, but the common workaround of adding a "wait" command:

on mouseup
    repeat with x = 1000 down to 0
       wait 0 with messages
       put x into fld 1
    end repeat
end mouseup

...allows the field to be updated (on OS X; I can't stress enough that 
this workaround is only needed on that one platform; Linux and Windows 
have no such issue, and once 6.7 is released OS X won't either).

Curious that the compiler doesn't complain - maybe it just ignores 
everything past the stuff it can use?

A quick test proves that hypothesis:

on mouseup
    repeat with x = 1000 down to 0 notwithstanding manbearbig
       wait 0 with messages
       put x into fld 1
    end repeat
end mouseup

...compiles just fine, even though "notwithstanding" is of course not a 
keyword, and we all recognize that the ManBearPig is mythical. ;)

Bug?

The compiler's errors are generally limited to those things the engine 
requires to be able to tokenize a script.  Ignored elements are 
anomalies, but apparently won't stop either compilation or execution.

Feature, perhaps? :)


> PS the thread is now out of control.

Maybe, but those of us who live for LiveCode trivia like this can't get 
enough. :)

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the Use-livecode mailing list