Jump to content

msgbox result


lyledg
 Share

Recommended Posts

Try to use functions. For example:

; Script start
;...blah blah...

;Here is the function you want to be repeated if the user presses No...
MyFunc()

;MsgBox goes here
$test = MsgBox(4,"Title","Press YES to continue or NO to repeat the last step")
If $test = 7 Then; 7 means "NO" was pressed
   MyFunc()
EndIf

...rest of code goes here...; means the user has pressed YES

; End of your code

Func MyFunc()
  ;here
  ;is your function's code
EndFunc

; End of script
Link to comment
Share on other sites

Here's what you need form the MsgBox() topic in the helpfile ..

Return Value

Success: Returns the ID of the button pressed.

Failure: Returns -1 if the message box timed out.

Return Value  Button Pressed

1 = OK 

2 = CANCEL 

3 = ABORT

4 = RETRY

5 = IGNORE 

6 = YES 

7 = NO 

10 = TRY AGAIN ** 

11 = CONTINUE ** 

HTH :)

Edit: Sample code:

( :) .. there's none in the helpfile! <-- opportunity for enhancement, someone?)

;stuff before the question
   ;stuff before the question
   ;stuff before the question

    While MsgBox(4096 + 4 + 32,@ScriptName,"Ready to continue?") = 7  ; 7 = NO
        sleep(10)
    Wend

   ;continue stuff
   ;continue stuff
   ;continue stuff
Edited by trids
Link to comment
Share on other sites

What I am trying to do is if a user clicks "No", it mus loop back to the original code, but if they click "Yes", continue the rest of code?

$Yes = 6
$No = 7
;Your code here

;Prompt user for an answer
$Answer = MsgBox(64 + 3, @ScriptName, "Do you want to exit?")
If $Answer = $Yes Then
  ;Do stuff
   Exit;if you want
ElseIf $Answer = $No Then
  ;Do stuff
EndIf
Link to comment
Share on other sites

I assume that he probably wanted a way to "goto" his code...

<{POST_SNAPBACK}>

You're right - I was just being lazy :)

Here's the reason we don't need GOTOs ..

Do ; <-- equivalent of a GOTO destination
       ;stuff until user says YES
       ;stuff until user says YES
       ;stuff until user says YES
       ;stuff until user says YES
    Until MsgBox(4096 + 4 + 32,@ScriptName,"Ready to continue?") = 6  ; 6 = YES
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...