How Does The Message Box Display The Result Of Executed Code

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

How Does The Message Box Display The Result Of Executed Code

Post by SirWobbyTheFirst » Sun Mar 01, 2015 4:00 pm

So, I am making a shell application which is modelled after the Message Box and I feel like this should be really easy but after combing the Message Box script to see how it does it, I am still baffled as to how the Message Box catches the results of some syntax say Put revLoadedStacks() and then displays them in the results field. I have tried checking to see if the IT variable and The Result function have contents but doing something as simple as Put The SystemVersion doesn't result in the value being put into the results field on my shell app.

Code: Select all

Do tCodeToExecute
If The Result <> Empty Then
   Put The Result Into Field 2 Of Me
Else If It <> Empty Then
   Put It Into Field 2 Of Me
End If
// Put Value(tCodeToExecute) Into Field 2 Of Me
It's crude I know but it's been baffling me for a while now, but this is what I have at the moment.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How Does The Message Box Display The Result Of Executed

Post by FourthWorld » Sun Mar 01, 2015 5:10 pm

The engine is hard-wired to look for a stack named Message Box, and use that for displaying unspecified puts.

But the team at RunRev has built in a nice if seldom-needed global property called revMessageBoxRedirect, which lets you redirect unspecified puts to any object you like.

Here's the relevant line from the init block in my Console tool, a drop-in replacement for the Message Box I made to address some nits I have with LC's:

Code: Select all

set the revMessageBoxRedirect to the long id of cd 1 of stack "4wConsole"
When not empty, the specified object will recieve msgChanged messages, in which the argument passed to it is the value to be displayed. Just handle that message however you like and you're good to go.

To let the LC IDE's Message Box resume normal behavior, just set the revMessageBoxRedirect to empty again.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: How Does The Message Box Display The Result Of Executed

Post by SirWobbyTheFirst » Sun Mar 01, 2015 5:54 pm

Hello Richard, good to hear from you again dude :)

I've been trying for the past hour or so to reimplement the code of the Message Box in a seperate stack including dependent functions so that I could use the debugger to step through the code and see if there was a method that I was just glossing over and the amount of code in the thing. Jeez, I felt like I was red pilling it up and about to break out of the Matrix at any moment. Hehe

But on a serious note, does the property exist in the standalone engine as well?

Thanks,
Mike.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9643
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How Does The Message Box Display The Result Of Executed

Post by dunbarx » Sun Mar 01, 2015 5:57 pm

Hi.

I see you take the time to "TitleText" each word in your scripts. Do you find that more readable? (Do You Find That More Readable?)

Just wondering...

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How Does The Message Box Display The Result Of Executed

Post by FourthWorld » Sun Mar 01, 2015 6:42 pm

mickpitkin92 wrote:Hello Richard, good to hear from you again dude :)
Back atcha, Mick. Seems it's been a while until I started seeing some of your posts here recently.
I've been trying for the past hour or so to reimplement the code of the Message Box in a seperate stack including dependent functions so that I could use the debugger to step through the code and see if there was a method that I was just glossing over and the amount of code in the thing. Jeez, I felt like I was red pilling it up and about to break out of the Matrix at any moment. Hehe
It's useful that the IDE code is available for all of us to review, but mostly for community contributions to the IDE itself rather than learning techniques that could be used in our own work.

The IDE has a great many considerations it needs to take into account to handle anything we can throw at it, but our own apps are often (thankfully) much simpler.

In short, the IDE's Message Box generally works well in the IDE, but I wouldn't dare invest the time to try to make it work in any other environment. It's just too dependent on other IDE components, so, as you've found, such an exercise quickly descends into madness. :)
But on a serious note, does the property exist in the standalone engine as well?
Indeed it does. One of the reasons I started work on my Console tool was to help me diagnose issues unique to the standalone environment. Without such an open-ended tool such exercises can be very time-consuming, requiring a mix of logging and sprinkling answer dialogs throughout and such, and constantly rebuilding and re-launching. But with a general-purpose Message Box-like tool I can call handlers and get global values and more on the fly. (I also made a simple lightweight standalone-compatible debugger, but that's another story).

Console is not yet stable, but once it is I'll be sharing it under GPL so everyone can play with it and modify it. May be a few weeks yet, though, as I have more pressing needs with some client projects.

In the meantime, exploring what you can do with revMessageBoxRedirect is time well spent IMO, since it opens the door to a wide range of useful diagnostic tools. And starting from scratch it definitely simpler than trying to coerce the IDE's Message Box. Try a few "do" and "value" things on the inputs, adding a line to set the defaultStack so the execution context is the topstack, and you'll be well on your way reasonably quickly.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: How Does The Message Box Display The Result Of Executed

Post by SirWobbyTheFirst » Sun Mar 01, 2015 9:04 pm

dunbarx wrote:Hi.

I see you take the time to "TitleText" each word in your scripts. Do you find that more readable? (Do You Find That More Readable?)

Just wondering...

Craig Newman
Erm...I don't know how it came to be exactly and now that I think about it, I don't seem to notice a difference between the lower case that everyone else uses and the title case that I use, I picked up Revolution back in September 2003 and I've done title case for as long as I can remember (The highly deteriorated text and symbol on my right shift key demonstrates this too well) so I wouldn't be surprised if I started doing it back when I started coding and at this point I think it is just muscle memory as I cannot for the life of me get myself to use lower case in LC. :P

I shall take your advice on board Richard, best of luck with your work, I have been tinkering with the new property, I did notice when I was perusing the Message Box code and its dependencies I noticed a couple of calls to something called _Internal, is that the engine? If so would you happen to know what it does? I'm not going to go messing around with that bit but I'm curious to see what it does.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How Does The Message Box Display The Result Of Executed

Post by FourthWorld » Sun Mar 01, 2015 9:32 pm

mickpitkin92 wrote:I did notice when I was perusing the Message Box code and its dependencies I noticed a couple of calls to something called _Internal, is that the engine? If so would you happen to know what it does? I'm not going to go messing around with that bit but I'm curious to see what it does.
There be dragons! :)

_internal is a catch-all for ad hoc solutions used by a rare and ever-smaller number of special needs for the IDE. I used to know a couple of the options for it, but those were old things I used to do when maintaining the MetaCard IDE, and haven't needed them since. With all the changes in the engine since then I doubt those older flags do anything anymore, and I'm not sure what current options exist.

If any hardy soul dares to hunt them down, here's where the dragons lie:
https://github.com/runrev/livecode
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: How Does The Message Box Display The Result Of Executed

Post by SirWobbyTheFirst » Mon Mar 02, 2015 4:18 pm

Well looking at the source code for LiveCode has just opened up some major PTSD, I'm getting the shakes all over again. I think with the engine being open source, it may be cool for the developers to possibly document the likes of _Internal and revMessageBoxRedirect even if they come with a warning message saying to exercise caution when using them as people like me could be curious as to what they do and may lack the ability to understand C++ enough to figure them out ourselves.

Also I seem to be on a role with reporting bugs with the engine this last week, I've reported three bugs so far, one with the Open File command, another with the FontNames function on Windows and just now another with the Alt+Space combo that displays the window menu on Windows. Feel quite chuffed with myself. :P

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How Does The Message Box Display The Result Of Executed

Post by FourthWorld » Mon Mar 02, 2015 4:50 pm

mickpitkin92 wrote:I think with the engine being open source, it may be cool for the developers to possibly document the likes of _Internal and revMessageBoxRedirect even if they come with a warning message saying to exercise caution when using them as people like me could be curious as to what they do and may lack the ability to understand C++ enough to figure them out ourselves.
I'm not sure if anyone but a handful of us enjoys such arcana, but since I do I'll be adding a new section to the revision to RevNet I'm working on, which will include info on the undocumented elements I've collected (all the way down to the long-since-deprecated-but-delightfully-mysteriously-named "mode14" <g>).
Also I seem to be on a role with reporting bugs with the engine this last week, I've reported three bugs so far, one with the Open File command, another with the FontNames function on Windows and just now another with the Alt+Space combo that displays the window menu on Windows. Feel quite chuffed with myself. :P
Thanks for filing those.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: How Does The Message Box Display The Result Of Executed

Post by SirWobbyTheFirst » Mon Mar 02, 2015 9:06 pm

I'm not sure if anyone but a handful of us enjoys such arcana, but since I do I'll be adding a new section to the revision to RevNet I'm working on, which will include info on the undocumented elements I've collected (all the way down to the long-since-deprecated-but-delightfully-mysteriously-named "mode14" <g>).
Ooooh goodie, I'd love to be notified when the new RevNet goes up as I might have some useful resources for other devs as I work on my own projects, will you be adding the ability for websites to cross link to resources on RevNet, because at some point I'd like to have a website going for my stuff and being able to provide a link to stuff I've put on RevNet would be quite nice and would drive others to discover other resources on there.
Thanks for filing those.
No problem.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How Does The Message Box Display The Result Of Executed

Post by FourthWorld » Mon Mar 02, 2015 9:15 pm

mickpitkin92 wrote:I'd love to be notified when the new RevNet goes up as I might have some useful resources for other devs as I work on my own projects, will you be adding the ability for websites to cross link to resources on RevNet, because at some point I'd like to have a website going for my stuff and being able to provide a link to stuff I've put on RevNet would be quite nice and would drive others to discover other resources on there.
If you have stack files to share there's no need to wait for the RevNet update: RevOnline should be working well now, and is the primary place for community stack sharing.

RevNet will offer a value of its own with other resources, but for security reasons I disabled public linking to downloadable sources some years ago, and am unlikely to take on the overhead of attempting to vet submissions in the future.

And with RevOnline back in action, that part of the older RevNet isn't needed much these days anyway.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Talking LiveCode”