very confuzing global variable and startup scripts

I have 2 script inside startup!

in one of them I have

rollout GroupOperations "Groups"
(
global disableselectog = 1
....
)

In another script also from startup I have
print disableselectog

and it says - undefined!

It is not because it is read later, because I use this value even in a button!

If I get the script print disableselectog and press CTRL+E - then it works, or if I get this script and drop on max then it reads this value!

Why when it runs by itself from startup it says undefined, but If I drag to max it finds the value of global variable?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
artrender.info's picture

THX Barigazy

now my script is finally working! Thank you so much! I can't find words to express my appreciation! I just had to put global variable outside of rollout

barigazy's picture

Because global variables or

Because global variables or local are declared only after you run the script. Difference is that global stay defined until your max is open. I not know how startup read scripts in folder. If it works in alphabetical order then named scripts in that way where first will be one with global variable.
But there is another way, put first in "StdPlugs/StdScripts" and the other in "startup". When you start program max first read files in stdscripts forder and then in startup.
Also you can read read variables or functions inside roll if your rollout are declared as global

try(destroyDialog ::bgaRoll)catch() --"::" like global
rollout bgaRoll "• • •"
(
	local arr = #(1,2,3)
	fn testfn = "Say hello!"
	button btn "test" pos:[5,5] width:50 height:20
	on btn pressed do
	(
		print "I'm pressed!"
	)
)
createDialog bgaRoll 60 30
-- now your roll works as struct
--you can call fn from inside
bgaRoll.arr
bgaRoll.testfn()
bgaRoll.btn.pressed()

I saw your mail. I answer you during the day

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.