Jump to content

Recommended Posts

Posted

I have an input box and if the input isn't one of the choices then I want a MsgBox saying so and giving the choice of running the input box again or cancel - ending the program.  Although I see that there is a MsgBox flag: $MB_RETRYCANCEL (flag 5) I can find no examples of how this works. 

$cnum = InputBox("ECJ_&_ECLI", "ECJ Case number? ", "T-457/09 or ECLI:EU:T:2014:683", "", -1, -1, 0, 0)
If StringInStr($cnum, "ECLI:") Then
    $cnum = StringReplace($cnum, ':', '%253A')
    $url = 'http://1xxx' & $cnum & 'xxx'
    ExitLoop
ElseIf StringInStr($cnum, "/") Then
    $cnum = StringReplace($cnum, '/', '%252F')
    $url = 'http://2xxx' & $cnum & 'xxx'
    ExitLoop
Else
    MsgBox(6, "Problem with your choice", "You haven't given me an ECJ Case_number or an ECJ ECLI", 10)
EndIf

Thanks for any help/hints

Posted

#include <MsgBoxConstants.au3>

ConsoleWrite(MsgBox($MB_RETRYCANCEL, '', 'Erm....') & @CRLF) ; $IDRETRY or $IDCANCEL is returned.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

#include <MsgBoxConstants.au3>

While 3
    $cnum = InputBox("ECJ_&_ECLI", "ECJ Case number? ", "T-457/09 or ECLI:EU:T:2014:683", "", -1, -1, 0, 0)
    If StringInStr($cnum, "ECLI:") Then
        $cnum = StringReplace($cnum, ':', '%253A')
        $url = 'http://1xxx' & $cnum & 'xxx'
        ExitLoop
    ElseIf StringInStr($cnum, "/") Then
        $cnum = StringReplace($cnum, '/', '%252F')
        $url = 'http://2xxx' & $cnum & 'xxx'
        ExitLoop
    Else
        If MsgBox($MB_RETRYCANCEL, "Problem with your choice", "You haven't given me an ECJ Case_number or an ECJ ECLI", 10) = $IDCANCEL Then
            ExitLoop
        EndIf

    EndIf
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

  • Solution
Posted

Or...

#include <MsgBoxConstants.au3>

Do
    $cnum = InputBox("ECJ_&_ECLI", "ECJ Case number? ", "T-457/09 or ECLI:EU:T:2014:683", "", -1, -1, 0, 0)
    If StringInStr($cnum, "ECLI:") Then
        $cnum = StringReplace($cnum, ':', '%253A')
        $url = 'http://1xxx' & $cnum & 'xxx'
        ExitLoop
    ElseIf StringInStr($cnum, "/") Then
        $cnum = StringReplace($cnum, '/', '%252F')
        $url = 'http://2xxx' & $cnum & 'xxx'
        ExitLoop
    EndIf
Until MsgBox($MB_RETRYCANCEL, "Problem with your choice", "You haven't given me an ECJ Case_number or an ECJ ECLI", 10) = $IDCANCEL

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Thanks guinness and JohnOne - two for the price (free) of one! My understanding is that guinness's version will allow me to make more input mistakes without exiting (this I need)

Posted

So does JohnOne's. I guess it's the while 3 that is confusing for some, but that's a JohnOne while loop!

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

Basically that can be while 1000000, it doesn't matter. It's still a continuous loop. The norm is While 1 or While True.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
  • Recently Browsing   0 members

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