Sign in to follow this  
Followers 0
nanetz

Alternative for Exit. Need something like exitloop

3 posts in this topic

OK guys.

My 1st post after working with autoit like 2 and half year. :D

Most of my scripts are kind newbies, and this Forum helped alot with almost all my doubts.

But now that i started to develop some script on GUI and i am having an odd issue.

I already tried to find on the forum but couldn´t find nothing about my issue.

Ok here is the deal.

On my script the data is verified after been sent to execution by the "Send" button.

I inserted a command to exit the script, after verified that the user and environments have same values on the from: and to:

What i´m looking for is a command or part of script to interrupt the CASE and keep running the program waiting for user to fix the data.

CODE
#include <array.au3>

#include <file.au3>

#include <GUIConstants.au3>

AutoItSetOption ( "WinWaitDelay", 1000 )

HotKeySet("{ESC}", "Terminate") ; create a hot key for the key escape

Func Terminate()

Exit 0 ; terminate the script

EndFunc

Dim $venv=0, $vuser=0

$frm_SAPP = GUICreate("Copy users", 393, 433, 193, 119)

$grupo_user = GUICtrlCreateGroup(" User Info ", 16, 8, 353, 205)

$lbl_requester = GUICtrlCreateLabel("User from:", 32, 48, 113, 17)

$userid = GUICtrlCreateInput("", 32, 68, 129, 21)

$checkuserid = GUICtrlCreateCheckbox("", 196, 68, 18, 18)

$lbl_requester2 = GUICtrlCreateLabel("User to:", 216, 48, 113, 17)

$userid2 = GUICtrlCreateInput("", 216, 68, 129, 21)

GUICtrlSetState(-1, $GUI_DISABLE)

$lbl_env = GUICtrlCreateLabel("Env from:", 32, 102, 75, 17)

$env = GUICtrlCreateInput("", 32, 122, 129, 21)

$lbl_env2 = GUICtrlCreateLabel("Env to:", 216, 102, 75, 17)

$env2 = GUICtrlCreateInput("", 216, 122, 129, 21)

$lbl_val = GUICtrlCreateLabel("Validity:", 32, 156, 48, 17)

$val = GUICtrlCreateInput("", 32, 176, 129, 21)

$checkkeep = GUICtrlCreateCheckbox ("Keep Roles?", 196, 156, 90, 20)

$checkkeep2 = GUICtrlCreateCheckbox ("Keep 2?", 196, 181, 90, 20)

$qtde = GuiCtrlCreateInput("0", 296, 176, 49, 21)

GuiCtrlCreateUpDown(-1) ;this will have a use in the future.

GUICtrlCreateGroup("", -99, -99, 1, 1)

$grupo_analista = GUICtrlCreateGroup(" Analyst Info ", 16, 218, 353, 153)

$lbl_user = GUICtrlCreateLabel("Login from:", 36, 253, 155, 17)

$user = GUICtrlCreateInput("", 34, 273, 129, 21)

$checkuser = GUICtrlCreateCheckbox("", 198, 277, 18, 18)

$lbl_user2 = GUICtrlCreateLabel("Login to:", 216, 253, 81, 17)

$user2 = GUICtrlCreateInput("", 218, 273, 129, 21)

GUICtrlSetState(-1, $GUI_DISABLE)

$lbl_pass = GUICtrlCreateLabel("Pass from:", 36, 307, 75, 17)

$pass = GUICtrlCreateInput("", 34, 329, 129, 21, $ES_PASSWORD )

$checkpass = GUICtrlCreateCheckbox("", 198, 329, 18, 18)

$lbl_pass2 = GUICtrlCreateLabel("Pass to:", 216, 307, 75, 17)

$pass2 = GUICtrlCreateInput("", 218, 327, 129, 21, $ES_PASSWORD )

GUICtrlSetState(-1, $GUI_DISABLE)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$send = GUICtrlCreateButton("Send", 136, 384, 105, 25, 0)

$btn_Cancel = GUICtrlCreateButton("Cancel", 256, 384, 105, 25)

GUISetState(@SW_SHOW)

Dim $avArray[300]

Func filldata() ;Fill data to variables.

Call("fillform")

$xid = GUICtrlRead($userid)

$xid2 = GUICtrlRead($userid2)

$xenv = GUICtrlRead($env)

$xenv2 = GUICtrlRead($env2)

$xval = GUICtrlRead($val)

$xuser = GUICtrlRead($user)

$xuser2 = GUICtrlRead($user2)

$xpass = GUICtrlRead($pass)

$xpass2 = GUICtrlRead($pass2)

;if GUICtrlRead($checkkeep) =

$xkeep = GUICtrlRead($checkkeep)

$xkeep2 = GUICtrlRead($checkkeep2)

If $xenv = $xenv2 Then ; Verify if the evironemnt´s have same values

$venv = 1

EndIf

MsgBox(4096, "Userid and Userid2", $xid&" "&$xid2)

MsgBox(4096, "Env and Env 2", $xenv&" "&$xenv2)

MsgBox(4096, "Result from Verify: 1 to equals and 0 to different", $venv) ;

MsgBox(4096, "Validity", $xval)

MsgBox(4096, "Logins", $xuser&" "&$xuser2)

MsgBox(4096, "Passwords", $xpass&" "&$xpass2)

MsgBox(4096, "Keep", $xkeep&" "&$xkeep2)

If $venv = 1 And $xid = $xid2 Then ; THIS IS THE CHECK. If verify env return 1 and the environments are the same Exit.

MsgBox(4096, "ERROR", "The userid´s and environments are equals. Please fill correctly.")

;$vexit = 1 ;I Thought to create a verify on this "IF" check and use on the Case commands.

ContinueCase

EndIf

EndFunc

Func fillform() ;Fill empty Forms

If GUICtrlRead($userid2) = "" Then

GUICtrlSetData($userid2, GUICtrlRead($userid))

EndIf

If GUICtrlRead($user2) = "" Then

GUICtrlSetData($user2, GUICtrlRead($user))

EndIf

If GUICtrlRead($pass2) = "" Then

GUICtrlSetData($pass2, GUICtrlRead($pass))

EndIf

EndFunc

Func verify_userid2()

If GUICtrlRead($checkuserid) = 1 Then

GUICtrlSetState( $userid2, $GUI_ENABLE )

GUICtrlSetState( $userid2, $GUI_FOCUS )

Else

GUICtrlSetState( $userid2, $GUI_DISABLE )

Endif

EndFunc

Func verify_user2()

If GUICtrlRead($checkuser) = 1 Then

GUICtrlSetState( $user2, $GUI_ENABLE )

GUICtrlSetState( $user2, $GUI_FOCUS )

Else

GUICtrlSetState( $user2, $GUI_DISABLE )

EndIf

EndFunc

Func verify_pass2()

If GUICtrlRead($checkpass) = 1 Then

GUICtrlSetState( $pass2, $GUI_ENABLE )

GUICtrlSetState( $pass2, $GUI_FOCUS )

Else

GUICtrlSetState( $pass2, $GUI_DISABLE )

EndIf

EndFunc

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $btn_Cancel

_ArrayDisplay($avArray, "_ArrayDisplay() Test")

Exit

Case $send

call ("filldata")

;Exit

Case $checkuserid

Call("verify_userid2")

Case $checkuser

Call("verify_user2")

Case $checkpass

Call("verify_pass2")

EndSwitch

WEnd

File Download

Share this post


Link to post
Share on other sites



Have you looked at ContinueCase()?


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

But already have a Continue Case on the verify.

Maybe I will need to change the script to verify on another part of the code.

Just to test, try entering a name on Userid from: and inserting "abc" on both environments.

What I expect to make on the script is that he wouldn´t quit the script but keep running and don´t loose the data.

By the way, thanks for the quick answer :D

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