MAXScript Message and Query Dialogs

These functions let you display a message box or a yes/no query dialogs from within MAXScript.

   

messageBox <message_string> [		title:<window_title_string>] [		beep:<boolean>] 	 

Displays a modal message box containing the message string and an OK button. The message box window title an be set with the title: keyword parameter. You can control whether a beep is made with the beep: keyword parameter, which defaults to true .

   

queryBox <message_string> [	 title:<window_title_string>] [	 beep:<boolean>]   

Displays a modal message box similar to the one that the messageBox() function creates, except it contains a Yes and a No button. The queryBox() function returns true if the user clicks Yes and false if the user clicks No.

   

yesNoCancelBox <message_string> [  title:<window_title_string>] [  beep:<boolean>] 

Displays a modal message box similar to the one that the messageBox() function creates, except it contains a Yes, a No, and a Cancel button. The yesNoCancelBox() function returns #yes , #no or #cancel depending on which button the user clicked to dismiss the message box.

FOR EXAMPLE:

messageBox "You shouldn't have done that"
if queryBox "Do you want to continue?" beep:false then...

In some cases, MAXScript statements occurring after a statement containing one of the above dialog function calls may be executed before they are supposed to be.

For example, if your execute:

SCRIPT:

for_t=0 to 3 do
(
messagebox "Press Me"
format "_t= %\n"_t
)
print "Should print last"

THE LISTENER WILL SHOW:

_t= 0
"Should print last"
"Should print last"
_t= 1
_t= 2
_t= 3

The MessageBox will be displayed 4 times, once each time before the value of _t is printed to Listener!

The reason for this is that Listener is looking for expressions to compile and run in a background thread. In the above example there are 2 expressions - the for loop expression and the final print expression. The messageBox() function goes on waiting for and processing UI events in the main UI thread, but the compiler has already compiled ahead and scheduled the print "Should print last".

To prevent this out-of-order execution, you need to bracket the script in parenthesis. This will force the sequencing to be correct because the script would now contain a single expression rather than two.