 ## Recommended Posts 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
For \$Index = 0 to 4 Step 1
\$Variable[\$Index]   = "null"
Next

WHILE StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 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 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
For \$Index = 0 to 4 Step 1
\$Variable[\$Index]    = "null"
Next

WHILE StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 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
\$Flag = 0

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

WHILE StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 5 AND StringLen(\$Variable) <> 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 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
For \$Index = 0 To 4 Step 1
\$Variable[\$Index] = "null"
Next

While StringLen(\$Variable) <> 5 And StringLen(\$Variable) <> 5 And StringLen(\$Variable) <> 5 And StringLen(\$Variable) <> 5 And StringLen(\$Variable) <> 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```

Live for the present,
Dream of the future,
Learn from the past. ##### 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
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 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!

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...