input cancellation question

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
lim0n
Newbie
Posts: 3
Joined: Thu Feb 26, 2009 11:42 pm

input cancellation question

Post by lim0n » Fri Mar 20, 2009 5:15 pm

How can i tell the script to cancel all actions if the user inputs 0 or nothing?

Thanks in advance!!

Label>Start
CapsOff
Let>ASK_TIMEOUT=20000
Ask>Run Script?,VarA
If>%VarA%=YES,IfYes,IfNo
Label>IfYes
Input>number,Enter number runs?,1
Let>x=0
Repeat>x
let>x=x+1
Label>begin
///script
End

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Mar 20, 2009 7:59 pm

If pressing ESC, the value will be "NO".
If closing the ASK window with the "X", the value will be "NO"
If Timed out (milliseconds) without any action, the value will be "YES"

Try this:

Code: Select all

Let>ASK_TIMEOUT=5000
Ask>Press Escape,vResult
MessageModal>The returned value is %vResult%
Oops, that was if no action was taken on ASK. I see you are asking about INPUT command, stay tuned.....

If pressing ESC, the value will be blank "".
If closing the INPUT window with the "X", the value will be blank "".
If Timed out (milliseconds) without pressing OK, the value will be blank "", no matter what was typed in.
If clicking on CANCEL, the value will be blank "".
All other actions return the value entered and accepted with the OK button, including the value of "0".

Try this:

Code: Select all

Let>INPUT_TIMEOUT=5000
Input>vResult,Enter number runs?,1
MessageModal>The entry is %vResult%
After the ASK/INPUT commands, just use an IF statement based on the value returned %vResult%.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Mar 21, 2009 9:00 am

Therefore to make the script exit and do nothing if either nothing or 0 is entered, or cancel is pressed::

Code: Select all

Input>number,Enter number runs?,1 
If>{(%number%="") OR (%number%="0")}
  Exit>0
Endif
You may want to extend that to verify the entry further.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts