Notifications
Clear all

[Closed] Way to stop execution?

Is there a way to pause the execution and wait for userinput?

One way I know of is MessageBox, since it will just pause everything, but it doesn’t have much buttons etc so it’s not that useful.

I haven’t tried yet, but another way could be to create a rollout that is modal.

The Sleep command can perhaps be used, i need the user to actually press buttons so not sure it would work either.

What I want to do is in a loop popup a window for every step letting the user step through the code. When they press Exit then they will just jump out of the loop.

The best way I can think of is queryBox, asking if the user wants to continue.

/Andreas

5 Replies

Hi Andreas,

Yo’ve probably thought of this but does progress bar help? they have a cancel button so the user could stop it whenever they liked.

J.

I prefer to script my own modal dialog boxs with what I need in them.

Instead of trying to pause a loop, just make it run a single iteration each time they click some button or press some specific key

1 Reply
(@f97ao)
Joined: 11 months ago

Posts: 0

Yea, that is pretty good actually.

I’m doing a really cool class that tests MaxScripts. You just write the code you want to test (could be an extrude2 or whatever), and it will try the code on all kinds of objects and different states. I hate it when a script crashes because you have a certain modifier on, and they have nothing selected AND showEndResult=on. Those bugs can be tricky to find otherwise.

/Andreas


global isRunning = true
global theRollout

-->FUNCTION:
-------------------------------------------------------------------------------------
fn theFunction =
(
for i in 1 to 10 do
	(
	if isRunning == true do
		(
		sleep 1
		print "Waiting"
		createDialog theRollout modal:true
		)
	)
)
-------------------------------------------------------------------------------------


-->ROLLOUT:
-------------------------------------------------------------------------------------
rollout theRollout "Continue?" width:160 height:88
(
	button btn1 "Stop" pos:[8,8] width:144 height:32
	button btn2 "Continue Script" pos:[8,48] width:144 height:32
	
	on btn1 pressed do
		(
		global isRunning = false
		destroyDialog theRollout
		)
	
	on btn2 pressed do
		(
		global isRunning = true
		destroyDialog theRollout
		)
)
-------------------------------------------------------------------------------------

theFunction()

Try running that and see if it does what you want. I just made the rollout modal, so it requires an input. In the loop, it checks the variable “isRunning” to see if it’s true or false. If true it continues through the loop, if false, it stops. When the continue button is pressed, it sets “isRunning” to true and removes the dialog, if “stop” is pressed, then is sets isRunning to false and removes the dialog.

I hope I understood what you were looking for.

-Dave