tyr(closeRolloutFloater) catch()doesn't work properly in different ways defining variable(local or global))


#1

hello everyone, i have encounter a closeRolloutFloater problem that really drive me nuts, i can’t find the reasonable solution from documentation. The problem is i want use try(closeRolloutFloater ) catch() to close the existing floater rollout window before open a new one, i try several ways to do it, but not all of them work. My code is below,

wrok:
1.
macroScript mycode category: “test”
(
rollout myrollout “test”
(
–code
)
try(closeRolloutFloater theNewFloater) catch()
local theNewFloater = newRolloutFloater “myrolloutfloater” 200 200
addRollout myrollout theNewFloater
)
2.
macroScript mycode category: “test”
(
rollout myrollout “test”
(
–code
)
try(closeRolloutFloater theNewFloater) catch()
global theNewFloater = newRolloutFloater “myrolloutfloater” 200 200
addRollout myrollout theNewFloater
)
3.
macroScript mycode category: “test”
(
global theNewFloater
rollout myrollout “test”
(
–code
)
try(closeRolloutFloater theNewFloater) catch()
theNewFloater = newRolloutFloater “myrolloutfloater” 200 200
addRollout myrollout theNewFloater
)
doesn’t work:
1.
macroScript mycode category: “test”
(
rollout myrollout “test”
(
–code
)
try(closeRolloutFloater theNewFloater) catch()
theNewFloater = newRolloutFloater “myrolloutfloater” 200 200
addRollout myrollout theNewFloater
)
2.
macroScript mycode category: “test”
(
local theNewFloater
rollout myrollout “test”
(
–code
)
try(closeRolloutFloater theNewFloater) catch()
theNewFloater = newRolloutFloater “myrolloutfloater” 200 200
addRollout myrollout theNewFloater
)

why it has to define the variable and seems at some particular position?


#2

you should define the rollout as global , you can’t get it if local
the 1st doesn’t work too


#3

Hello AEI, thanks for help. But i am still confused because i see some other scripts don’t define the rollout as global or local, but it still run well, why it works?


#4

when variable define at top level , it is global , otherwise is local