Stupid question on the use-list

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Stupid question on the use-list

Post by dunbarx » Tue Nov 10, 2020 7:53 pm

On a card with a field 1 and a button, this in the btn script:

Code: Select all

on mouseUp
   put "start"into fld 1
   wait 5 seconds
   put "stop" into fld 1
end mouseUp
Works just fine. Why wouldn't it? But now try substituting the message box for fld 1. The "start" never appears. There were reasons mentioned for this, and I am not at all sure about them

So the question is: "Why does it not work the same with the message box?" And I know the message box is a mysterious entity.

Craig

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

Re: Stupid question on the use-list

Post by FourthWorld » Tue Nov 10, 2020 8:38 pm

The Message Box contents are driven by messages. This was added several versions ago to facilitate alternative message box UIs and debugging tools.

Being message-driven, it will show updates at idle.

You can allow messages to be sent in the middle of other processing by adding the "with messages" clause to the wait statement.
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: 10339
Joined: Wed May 06, 2009 2:28 pm

Re: Stupid question on the use-list

Post by dunbarx » Tue Nov 10, 2020 8:44 pm

Richard.
The Message Box contents are driven by messages
What isn't? The handler sees msg as a container, no? Just like that field. What happens to the instruction to place a string into message that does not happen when placing that string into a field? How does msg "block" (ignore?) the instruction in the handler after it has already executed?

Or does the handler "know" that the destination of that line of code is special, in that it is the message box, and therefore acts differently? Does it know this early enough not to properly complete that line of code for the same reason? Does msg not accept it for some reason?

I have no sense of the distinction. :cry:

Craig

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

Re: Stupid question on the use-list

Post by FourthWorld » Tue Nov 10, 2020 9:12 pm

dunbarx wrote:
Tue Nov 10, 2020 8:44 pm
Richard.
The Message Box contents are driven by messages
What isn't?
Commands and functions.

What happens when you add the "with messages" clause to the wait statement?
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: 10339
Joined: Wed May 06, 2009 2:28 pm

Re: Stupid question on the use-list

Post by dunbarx » Tue Nov 10, 2020 11:10 pm

Richard.

I know that waiting with messages allows the message box to receive the string "start".

My question is why doesn't a field need that, or rather, why does message absolutely need it?

What is the difference, apart from the message box being a separate stack? Before you answer, know that if the target field was in fact on a separate stack, the handler works perfectly normally; it does not need to wait with messages. It can just wait.

So it is not that the loading of the string is not local. It is the message box itself that is the outlier case. I am just wondering what the distinction is. 8)

Craig

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

Re: Stupid question on the use-list

Post by FourthWorld » Wed Nov 11, 2020 12:18 am

dunbarx wrote:
Tue Nov 10, 2020 11:10 pm
My question is why doesn't a field need that, or rather, why does message absolutely need it?
Message Box contents are not handled via the same mechanisms as other means of putting contents into fields.

The Message Box contents are driven by messages. This was added several versions ago to facilitate alternative message box UIs and debugging tools.

In this new arrangement, Message Box contents are updated in response to a msgChanged message. This change was documented in the v9.0 Release Notes (dp5 and later) for developers who had been using the older revMessageBoxRedirect global property (which AFAIK was only the IDE team and myself):
The way the message box functions has been refactored:
- the IDE only global property revMessageBoxRedirect has been removed
- the IDE only global property revMessageBoxLastObject has been removed
- the legacy message box behavior setting the text of the first field of a stack named Message Box has been removed
- the msgChanged message is now sent to the object that changed the message
- IDE plugin developers should subscribe to ideMsgChanged for custom message boxdevelopment.
- If the msgChanged message is not handled the content of the message box will be logged to the system log unless the engine is running in no ui (command line) mode which will write thecontent to STDOUT.revvideograbberend-of
Here's the msgChanged handler used in LC's IDE (see the revIDEMessageHandlerLibrary" frontScript):

Code: Select all

on msgChanged pHandler, pLine
   local tTarget
   put the long id of the target into tTarget
   
   local tParams
   put tTarget into tParams[1]
   put pHandler into tParams[2]
   put pLine into tParams[3]
   put msg into tParams[4]
   send "ideMessageSendWithParameters" &&  "ideMsgChanged, tTarget, tParams" to stack "revIDELibrary" in 0 milliseconds
   pass msgChanged
end msgChanged
Their use of "send...in <time>" accounts for the seeming anomaly.
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: 10339
Joined: Wed May 06, 2009 2:28 pm

Re: Stupid question on the use-list

Post by dunbarx » Wed Nov 11, 2020 3:04 am

Richard.

OK, I even understand that. No wonder the message box is peculiar.

Thanks.

Craig

Post Reply