ScriptSpot

Forum topic · Scripts Wanted

Reoccurring Dialog

By JokerMartini · 2012-02-13

Description

How would I go about creating a dialog the continuously creates a rollout until the numbered limit is up, or if the user hits Cancel the whole operation is terminated.

fn fnCounter = (
for i = 1 to 4 do
(
global loopCount = i

rollout rlCool ""
(
button btnGo "GO"
button btnCancel "Cancel"
label lbLoopCounter "1"

on rlCool open do
(
lbLoopCounter.text = loopCount as string
)
)
createDialog rlCool 150 150
)
)
clearlistener()
fnCounter()

Comments (5)

JokerMartini · 2012-03-02

Thanks guys for the examples I'll go ahead and try these out and see what works best for my situation.

JokerMartini · 2012-02-13

I would want it to progressive execute. Not all at once. So if the user says ok to the first rollout it then creates the second and so forth. but if they hit cancel at any point it just stops.

Anubis · 2012-02-13

for i = 1 to countLimit while \
not keyboard.escPressed do
(
	-- build the rollout as string
	strDefinition = ...
	-- and execute
	execute strDefinition
)

and if the question is how to abort the process by pressing btnCancel inside your rollouts, then just use global variable:

on btnCancel pressed do
(::ACT_CANCELED = true)

...and your for-loop w'd become something like:

global ACT_CANCELED = false
for i = 1 to 4 while not ACT_CANCELED do...

You can also use two scripts

LittleLordPotala · 2012-02-13

1) Copy both scripts in your current script folder
2) launch "test0.ms"
3) click "Go" button
4) if you want to cancel, you can hold down the ESC key

Attachments

for i = 1 to 4

miauu · 2012-02-13

[code]
for i = 1 to 4 do
(
rol_Name = "rlCool" + (i as string)
str = "rollout " + rol_Name+ " \"\" ("
str += "button btnGo \"GO\""
str += "button btnCancel \"Cancel\""
str += "label lbLoopCounter \"1\""
str += "on rlCool open do lbLoopCounter.text = loopCount as string"
str += ")"
str += "createDialog " + rol_Name+" 150 150"
execute str
)
clearlistener()
[code]