Sign in to follow this  
Followers 0
Guest duomenox

InputBox Question about Cancel

5 posts in this topic

#1 ·  Posted (edited)

Hello everyone,

I have a script that asks for user input. I am not using the GUI Controls as it would take a much longer time to write.

I have a couple input boxes that I am asking the user to input 5 sets alpha numeric values of 5 digits each. I am then checking the strings to make sure they are 5 charactors and that all charactors are alpha numeric (no symbols).

Here is my code:

;Declare and Set the $Variable[Array]
Dim $Variable[5]
For $Index = 0 to 4 Step 1
    $Variable[$Index]   = "null"
Next

WHILE StringLen($Variable[0]) <> 5 AND StringLen($Variable[1]) <> 5 AND StringLen($Variable[2]) <> 5 AND StringLen($Variable[3]) <> 5 AND StringLen($Variable[4]) <> 5;Checks for correct number of chractors in each block of the Variable.
    FOR $Index = 0 to 4 Step 1
        $Variable[$Index]   = InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", "Please enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF, "", " M5", 300, 162)
        WHILE StringLen($Variable[$Index]) <> 5 = StringIsAlNum($Variable[$Index])
            $Variable[$Index]   = InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", "Please re-enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF , $Variable[$Index], " M5", 300, 162)
        WEND
    NEXT
WEND

1. If the user clicks cancel on the block 1 of 5 ;then it goes to block 2 of 5.

2. If the user click cancel on all blocks, it loops back and asks for block 1 again.

3. If the user inputs any symbols or the legnth is not 5 charactors it will ask the "re-enter" dialog.

Any ideas on how I can disable the cancel button, or modify the script to loop that current block if the cancel button is pressed?

Any input would be appreciated, Thank you!

Edited by duomenox

Share this post


Link to post
Share on other sites



Hello everyone,

I have a script that asks for user input. I am not using the GUI Controls as it would take a much longer time to write.

I have a couple input boxes that I am asking the user to input 5 sets alpha numeric values of 5 digits each. I am then checking the strings to make sure they are 5 charactors and that all charactors are alpha numeric (no symbols).

Here is my code:

;Declare and Set the $Variable[Array]
Dim $Variable[5]
For $Index = 0 to 4 Step 1
    $Variable[$Index]    = "null"
Next

WHILE StringLen($Variable[0]) <> 5 AND StringLen($Variable[1]) <> 5 AND StringLen($Variable[2]) <> 5 AND StringLen($Variable[3]) <> 5 AND StringLen($Variable[4]) <> 5;Checks for correct number of chractors in each block of the Variable.
    FOR $Index = 0 to 4 Step 1
        $Variable[$Index]    = InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", "Please enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF, "", " M5", 300, 162)
        WHILE StringLen($Variable[$Index]) <> 5 = StringIsAlNum($Variable[$Index])
            $Variable[$Index]    = InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", "Please re-enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF , $Variable[$Index], " M5", 300, 162)
        WEND
    NEXT
WEND

1. If the user clicks cancel on the block 1 of 5 ;then it goes to block 2 of 5.

2. If the user click cancel on all blocks, it loops back and asks for block 1 again.

3. If the user inputs any symbols or the legnth is not 5 charactors it will ask the "re-enter" dialog.

Any ideas on how I can disable the cancel button, or modify the script to loop that current block if the cancel button is pressed?

Any input would be appreciated, Thank you!

<{POST_SNAPBACK}>

Try this... I left some extra code for the _ArrayDisplay, so you can see that it doesn't mess with your array.

#include <array.au3>

;Declare and Set the $Variable[Array]
Dim $Variable[5]
$Flag = 0

For $i = 0 to 4 Step 1
    $Variable[$i]   = "null"
Next

WHILE StringLen($Variable[0]) <> 5 AND StringLen($Variable[1]) <> 5 AND StringLen($Variable[2]) <> 5 AND StringLen($Variable[3]) <> 5 AND StringLen($Variable[4]) <> 5;Checks for correct number of chractors in each block of the Variable.
    FOR $Index = 0 to 4 Step 1
        if $Flag = 1 then $Index = $Index -1
        $Variable[$Index]   = InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", "Please enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF, "", " M5", 300, 162)
        if @Error = 1 Then 
            $Flag = 1
        Else
            $Flag = 0
        EndIf
        WHILE StringLen($Variable[$Index]) <> 5 = StringIsAlNum($Variable[$Index])
            $Variable[$Index]   = InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", "Please re-enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF , $Variable[$Index], " M5", 300, 162)
        WEND
    NEXT
WEND

_ArrayDisplay($Variable, "Test")

Kerby

Share this post


Link to post
Share on other sites

Any ideas on how I can disable the cancel button, or modify the script to loop that current block if the cancel button is pressed?

Any input would be appreciated, Thank you!

<{POST_SNAPBACK}>

Don't understand exactly what you want to do in case of Cancel but heres an example that will exit the second While...wend loop when Cancel is pressed:

;Declare and Set the $Variable[Array]
Dim $Variable[5]
For $Index = 0 To 4 Step 1
    $Variable[$Index] = "null"
Next

While StringLen($Variable[0]) <> 5 And StringLen($Variable[1]) <> 5 And StringLen($Variable[2]) <> 5 And StringLen($Variable[3]) <> 5 And StringLen($Variable[4]) <> 5;Checks for correct number of chractors in each block of the Variable.
    For $Index = 0 To 4 Step 1
        $Variable[$Index] = InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", "Please enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF, "", " M5", 300, 162)
        While StringLen($Variable[$Index]) <> 5 = StringIsAlNum($Variable[$Index])
            $Variable[$Index] = InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", "Please re-enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF, $Variable[$Index], " M5", 300, 162)
            If @error = 1 then exitloop 
        WEnd
    Next
WEnd

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Here is a re-write to accomplish what you want. Some of this is spread out to make the logic more readable.

;Declare and Set the $Variable[Array]
Dim $Variable[5]
For $Index = 0 to 4 Step 1
    $Variable[$Index]    = "null"
Next
$Index = 0
$All_Done = 1
WHILE 1
        WHILE 1
            IF (StringLen($Variable[$Index]) = 5 ) and ( StringIsAlNum($Variable[$Index])) then exitloop
            $All_Done = 0
            $Pmt = "Please enter block " & $Index + 1 & " of your 5 block Variable:" & @CRLF
            if $Variable[$Index] = "null" then $Dft = "[ENTER 5 DIGIT ALPH-NUMERIC]"
            $Rslt =  InputBox("Variable Entry, Box " & $Index + 1 & " of 5.", $Pmt, $Dft, " M5", 300, 162)
            if @Error <> 0 then ExitLoop 
            if $Dft <> $Rslt then $Variable[$index] = $Rslt
        WEND
    
   $Index = $Index + 1
   if $Index > 4 then
       iF $All_Done then ExitLoop
       $Index = 0
       $All_Done = 1
   endif


   
WEND

Share this post


Link to post
Share on other sites

Thanks for all your input everyone. I was able to get it working with the suggestions everyone made.

Sorry about the messy script, I've been in such a hurry trying toget this done I have taken some extra liberties with cleanliness :-P

Again, thank you for your help!

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