Passing parameters to rollouts


I’m using Max Script. I’d like to pass some parameters to a rollout, just like you would normally specify in a class’ constructor. Rollouts do not seem to have such an ability. Or do they?

I know I could access locals in a rollout directly, but their values get reset upon initialization, which is not good for what I need.

Currently what I do is I created a struct available globally, with the members, to which I assign values before I call ‘createDialog’. This way
my rollout will read the data from that struct.
But that seems a bit cumbersome…

Is there any more elegant way to do it?


I usually access local variables because in my case I don’t need to save their values outside rollout’s screen life.

Global struct is not that bad.


you could do it as a Custom Attribute with local variables and/or parameter blocks, right?


They get set to whatever value is assigned to them in the rollout, you can reassign them to itself and they will hold the same value:

rollout varTest ""
	local str = if isKindOf str String then str else "Default"
	button btnStr str

varTest.str = "Override"
createDialog varTest


And of course you can use an ‘*.ini’ file to load values in the ‘on open’ event and save them in the ‘on close’ one.


Thanks everyone for your answsers. All are good ideas, however I probably will go for this one, for what I need:

I’d never think about assigning variable to itself, based on type etc… Really cunning idea.
Thanks again!


Like most of the other brilliant ideas, I first saw this one used by denisT, and didn’t look back ever since :slight_smile: