discuss on DestroyDialog

discuss on DestroyDialog

Anonymous
Not applicable
393 Views
5 Replies
Message 1 of 6

discuss on DestroyDialog

Anonymous
Not applicable
When I write codes about rollout and dialogs and then debugging them, I always use destroydialog( ) and createDialog ( ) to "update" the rollout I'm working with.

consider these codes:

code A:

if theRollout != undefined then destroyDialog theRollout

rollout theRollout "....."
(
......
)

createDialog theRollout


code B:

rollout theRollout "....."
(
......
)

if theRollout != undefined then destroyDialog theRollout
createDialog theRollout


Well, Code A works fine, while Code B doesn't.

I figure that in code B, when it comes to the statement " destroyDialog theRollout ", theRollout has already been redifined , and the "theRollout" which destroyDialog( ) trying to destroy here is actually not a dialog at the time. The dialog which is created last time is not "theRollout" now. So in code B, when it comes to "destroyDialog theRollout", nothing will happen. Am I right?

On the other hand, Code A is not so convenient since the rollout definations are always extremely huge in size.
Is there any other way to "update" the dialog when debugging it ?
0 Likes
394 Views
5 Replies
Replies (5)
Message 2 of 6

Steve_Curley
Mentor
Mentor
(
rollout test "test"
(
-- whatever
)

try (destroyDialog test) catch()
CreateDialog test
)


Not had any problems with rollout definitions doing it that way.

You're destroying the current instance of the dialog (if any) and creating a new one (with the current definition). I can't quite see how that wouldn't work.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 3 of 6

Anonymous
Not applicable
Case B will not work right because the IF will always see the rollout as defined, but the rollout that is defined has already OVERWRITTEN the rollout that was displayed as dialog previously.

createDialog() does not create a new object, it changes the display "mode" of the rollout to show up as floating dialog. Thus, the rollout you are closing as dialog should be the same one you opened, but the rollout() definition kills the previous one.

The way I ALWAYS do it is this:

(--start local scope
global MyGlobalRolloutDefinition --declare a global variable for the rollout, must be rather unique
try(destroyDialog MyGlobalRolloutDefinition)catch() --close if open, ignore if not defined yet

rollout MyGlobalRolloutDefinition "My Dialog"
(
label lbl_text01 "Hello World!"
)

createDialog MyGlobalRolloutDefinition
)--end script and local scope


This is different when using NewRolloutFloater() and CloseRolloutFloater() because a rollout floater is its own object and can be destroyed even after the rollout definitions.
0 Likes
Message 4 of 6

Anonymous
Not applicable
to Bobo :
I totally agree with you about the reason that why code B will not "update" the following rollout when rerunning.

-----

What I'm really care is thet is there any workarround to achieve the same "update" ? The codes you showed upstairs are also divide into two parts by a huge block of rollout definations.

I'm now work with a project which concerned with lots of rollouts. A little progress will help a lot. And i do think it's kind of important to all of us.So I bring on this discussion.

all the advices will be appreciated.
0 Likes
Message 5 of 6

Anonymous
Not applicable
If a script is going to create one or more rollouts, I add a try/catch at the beginning as Bobo described:
try(destroyDialog MyRolloutDefinition)catch()

I'm not sure I understand your objection to this approach. If it is to handle scripts that are too long, you should consider putting them in separate files and run them with fileIn.
0 Likes
Message 6 of 6

Anonymous
Not applicable
Thanks stokes. it seems we all use the same way.
0 Likes