[Closed] Execute() is cutting in line of compile order?
Hi, this thing makes absolutely no sense to me, this script works perfectly if you’ve runned it twice, but if you start it from a freshly restarded 3dmax it will error.
It seems it checks if the button exist before the button has been spawned, but that doesn’t make sense because the order clearly says that the button is spawned first.
Anyone have any idea?
if true then --If I don't use a IF command the script works as well
(
rollout testRoll "Test Roll" category:2
(
button testButton "Test Button"
)
testWindow = newRolloutFloater "Test Window" 505 595
addRollout testRoll testWindow rolledUp:false
testRoll.testButton.text = "Changed name" --Works
execute("testRoll.testButton.text = \"Changed name2\"") --Doesn't work, unless I run the script twice
)
I had some trouble with the ” recently and solved it by doing something like:
s=“testRoll.testButton.text = “”
s+=“Changed name”
s+=”””
Maybe it helps… who knows!
edit: And of course, after that do Execute(s)
Hi
I think this is a scope issue.
execute runs in global scope,
and since you have the rollout defined in local scope (if statement)
the rollout is not recognized.
I think you need to define the rollout var as a global, then it should work.
[left] [/left]
[left]
[left]if true then --If I don't use a IF command the script works as well
([/left]
[left] global testRoll[/left]
[left]
rollout testRoll "Test Roll" category:2
(
button testButton "Test Button"
)
testWindow = newRolloutFloater "Test Window" 505 595
addRollout testRoll testWindow rolledUp:false
testRoll.testButton.text = "Changed name" --Works
execute("testRoll.testButton.text = \"Changed name2\"") --Doesn't work, unless I run the script twice
)[/left]
[/left]
Try it like this:
rollout testRoll "Test Roll" category:2
(
button testButton "Test Button"
)
testWindow = newRolloutFloater "Test Window" 505 595
addRollout testRoll testWindow rolledUp:false
testRoll.testButton.text = "Changed name" --Works
execute("testWindow.rollouts[1].testButton.text = \"Changed name2\"") --Doesn't work, unless I run the script twice
This way you acces the rollout as one of the rollouts inside the Floater…should work
MarcoBrunetta: That “worked”, but only because you didn’t include the If’s (which I need), when adding those it had the same error.
Kameleon: No :), but thanks anyway.
Zbuffer: mmmm sounded like BS at first, but damn, you’re a genious, it works