PDA

View Full Version : Execute() is cutting in line of compile order?


Niber
03-28-2008, 12:24 PM
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
)

Kameleon
03-28-2008, 12:32 PM
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) :P

Zbuffer
03-28-2008, 02:07 PM
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.

if true then --If I don't use a IF command the script works as well
(
global testRoll

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
)

MarcoBrunetta
03-28-2008, 06:17 PM
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

Niber
03-31-2008, 09:56 AM
MarcoBrunetta (http://forums.cgsociety.org/member.php?u=314248): That "worked", but only because you didn't include the If's (which I need), when adding those it had the same error.

Kameleon (http://forums.cgsociety.org/member.php?u=109790): No :), but thanks anyway.

Zbuffer (http://forums.cgsociety.org/member.php?u=25187): mmmm sounded like BS at first, but damn, you're a genious, it works :D

CGTalk Moderation
03-31-2008, 09:56 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.