Notifications
Clear all

[Closed] update listbox in another rollout

Hello guys !

I have a problem. I made a script to rename several objects in same time. I put a foolproof utility that show in a dialogbox a list of ignored objets for several reason.
So, i wanna change this and put the list of objects in a listbox in another rollout in the same rolloutfloater.
I was create a function to command the updating of the listbox and a label.text that give some informations about this objects.
But my problem is : If i put the function in the rollout of the listbox, the first rollout doesn’t see it. If i put the function in the another rollout the function doesn’t see the listbox. I try to put it out of the both rollout with a Global term but the function doesn’t see the listbox.

Do you have a way to updating the listbox in a rollout with a global array in an other rollout passing by a function ?

Thanks for your help.

6 Replies

Try using the rollount name dot listboxname dot items. For example if the rollout name is myRollout and the listbox name is myListBox then you would call it’s items like this: myRollout.myListBox.items

 eek

you could call the function from a struct outside all the rollouts – but you’d have to instance it.

 struct test 
(
a = 0,
b = 0,
 
fn testfn = ( a + b),
 
endofstruct
)
test01 = test()
 
rollout testRoll ""
(
spinner sp1 "a"
spinner sp2 "b"
 
button bt1 "Call function"
 
on sp1 changed val do
(
test01.a = val
)
 
on sp2 changed val do
(
test01.b = val
)
on bt1 pressed do
(
messagebox (test01.testfn() as string)
)
 
 
on testroll open do
(
test01.a = sp1.value
test01.b = sp2.value
)
)
createdialog testRoll

vasilescu_anton :
I try your tip but i have an error. I will try it again.

eek :
Your code seems to work. I will test some ways to adapt your code.

thanks a lot for your help.

2 Replies
(@johnswafford)
Joined: 11 months ago

Posts: 0

I use anton’s technique extensively, and as long as the rollout definition is global this approach will work. If you are having an error, there must be a syntax error in your code.

By the way, you can also trigger any of the local functions defined within the rollout using the same technique: MyRollout.MyFunction()

(@magicm)
Joined: 11 months ago

Posts: 0

Like John said this is probably a scope issue. You’ll need to make sure that the rollout which contains the function is declared before the containing function is called. Here’s a simple example:

( -- begin level 1 context

rollout myRolloutA "Rollout A"
( -- begin level 2 context
	fn myFunctionA = messageBox "Function A"

	button btnA "myRolloutB.myFunctionB"
	on btnA pressed do myRolloutB.myFunctionB()
) -- end level 2 context

rollout myRolloutB "Rollout B"
( -- begin level 2 context
	fn myFunctionB = messageBox "Function B"

	button btnB "myRolloutA.myFunctionA"
	on btnB pressed do myRolloutA.myFunctionA()
) -- end level 2 context

createDialog myRolloutA
createDialog myRolloutB

) -- end level 1 context

Pressing the button on rollout b calls the function in rollout a without problems. However, the other way around generates an error, since rollout b hasn’t been created yet at the time rollout a is created. Make sure you read the Scope of Variables topic in the online reference as it explains very well what scope contexts are and how to to work with them.

Cheers,
Martijn

JohnSwafford and magicm :
I don’t understand how to use the tip of vasilescu_anton.
But i think i understand yours. I will try it. Thanks a lot for your help

I’am asking this question for this script : MassRenommer v2.1.

You can find it in this thread : http://forums.cgsociety.org/showthread.php?p=4487080#post4487080

Tell me what do you think about it.