Jump to content

stopping script when clicking cancel


Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

qq

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...