Sign in to follow this  
Followers 0
apsync

stopping script when clicking cancel

6 posts in this topic

hmm for some reason this function is not working, i want to exit the script immediately if user has pressed cancel!

Func CheckForNo($F)
  If $F = 2 Then
    Exit
  EndIf
EndFunc

$times = InputBox("", "question 1");
CheckForNo($times)

$cpnaam = InputBox("", "question 2");
CheckForNo($cpnaam)

$bericht = InputBox("", "question 3");
CheckForNo($bericht)

it's not working, when I press cancel it still asks the next question!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

i'm not the smartest here but.... i m sure you need to "call"

$times = InputBox("", "question 1");

Call ("CheckForNo($times)")....????

why not use

$msg = GuiGetMsg()

$times = InputBox("", "question 1");

if $msg= $Cancel_button then ExitLoop ; exits a loop

If $msg = $GUI_EVENT_CLOSE then exit ; exits the program

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

thx for the reply, no i dont want to use guigetmsg, and no the call function is not working, but thanks for the reply though, anyone else?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

2 is the @error value, read the help file. The string returned when cancel is clicked is nothing. This works fines. I changed the "2" to '""'

$times = InputBox("", "question 1");
CheckForNo($times)

$cpnaam = InputBox("", "question 2");
CheckForNo($cpnaam)

$bericht = InputBox("", "question 3");
CheckForNo($bericht)

Func CheckForNo($F)
  If $F = "" Then
    Exit
  EndIf
EndFunc

What I would like to know is why this doesn't work...

$times = InputBox("", "question 1")

If @error = 2 Then
   Exit
EndIf

$hhh = InputBox("", "question 2")

Edit: Sorry Helge. If you combine your answer and mine we would have a nice one lol. I must be tripping out. I checked the help file for the @error return for the input box function and I SWEAR it said it was 2... I check it know and it says its 1. Please disregard my stupid last "What I would like to know..." question as I was going on the assumption that @error = 2 when the cancel is pressed but really its when the timeout is reached.

Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You've not set up the script to exit when the user presses "Cancel",

but when the user inputs "2". See the code below...

$times = InputBox("", "question 1");
CheckForNo(@ERROR)

$cpnaam = InputBox("", "question 2");
CheckForNo(@ERROR)

$bericht = InputBox("", "question 3");
CheckForNo(@ERROR)

Func CheckForNo($F)
  If NOT $F = 0 Then Exit; Quits at error
EndFunc

Edit : Too slow.. Anyway, you might want to check out Burrup's

script instead of mine, as his also fails when the user haven't input

anything. If you want that..

Good luck with your script !

Edited by Helge

Share this post


Link to post
Share on other sites

thx!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0