Notifications
Clear all

[Closed] loop in rollout?

I’m trying to get a rollout to make a list of buttons based on an array. At the moment I am getting an error :-

– Syntax error: at for, expected <rollout clause>
– In line: for 1

Does this mean that you can’t place loops within a rollout definition? If so, is there a workaround that allows you to make a rollout that builds a list of options based on the number of items selected… like the light lister.

Am I forced to use the rolloutcreator?

2 Replies

Haha oops, didn’t realize you mentioned rolloutCreator already. But yea I think that’s the only way.

You don’t have to use RolloutCreator, but I think it pretty much does the same thing as I’m about to example anyway. RolloutCreator just puts all of this into a nice workable struct.

str = "rollout ro_test \"Test\" (
"
 
 for i = 1 to 5 do (
 -- UI Declaration
 str += "button bt_" + i as string + " \"Button_" + i as string + "\"
"
 
 -- Event handlers
 str += "on bt_" + i as string + " pressed do (
"
 str += "messagebox \"You pressed button " + i as string + "\"
"
 str += ")
"
 )
 str += ")
"
 
 createDialog (execute str) width:300 height:200

That should work.