Notifications
Clear all

[Closed] I hate you on isChecked

How come something like this:


macroScript test
category: "testcripts"
(
	on isChecked do testfloater != undefined 
	on execute do (global testfloater = newRolloutFloater "testfloater" 201 600 20 70 )
	on closeDialogs do 
	(
		closeRolloutFloater testfloater
		testfloater = undefined
	)
)

works ok if I evaluate the script manually but on restarting MAX and pressing the button it creates a new instance of the floater repeatedly.
Re-evaluating the code manually once agains makes the code work ok… what am I doing wrong?

2 Replies

this looks like global/local scope issue … if you change it like this:


(
 global testfloater
 on isChecked do (testfloater != undefined)
 on execute do (testfloater = newRolloutFloater "testfloater" 201 600 20 70 )
...


and it sees the one and only testfloater ( or so me think … )

Yup that seems to do the trick… darned global variables. Thanks