monte Posted February 24, 2006 Share Posted February 24, 2006 hello, I want to test for an error and continue loop if occurs instead of crashing my script. Specifically, my data is copied from the clipbaord and then used in my function. If however, the correct data isn't in the clipboard, the script fails, see $vServer=$vServerString[22] below. Instead of crashing, I want to be able to continue loop. Thanks for any help you may be able to provide. here's my code: expandcollapse popup #include <GUIConstants.au3> #include <array.au3> #notrayicon $checkRun = "Emc Script" If WinExists($checkRun) Then Exit GUICreate("Emc Script", 350, 210) GUISetBkColor (0xA9A9A9) $button1 = GUICtrlCreateIcon ("C:\progra~1\pa.bmp",-1,10,10) ; pa GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $button1 pa() if @error then continueloop EndSelect WEnd func pa() seterror(1) If WinExists("pa") Then $vServerClip=clipget() $vServerString=stringsplit($vServerClip,@TAB) $vServer=$vServerString[22] WinActivate("pa") sleep(1000) Send("{F10}tf") Send($vServer) send("{TAB}a") Send("{ENTER}") sleep(1000) send("{ENTER}") else global $mycmd="C:\progra~1\citrix\icacli~1\pn.exe /pn:" & '"farm"' & ' /app:"pa Client"' Dim $primary Dim $secondary $k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons") If $k = 1 Then $primary = "right" $secondary = "left" else $primary = "left" $secondary = "right" endIf msgbox(1,"","Opening pa, please have your rsa token ready. If the server search does not commence upon entering, please reclick the pa icon.", 20) run($mycmd) WinWaitActive("pa") winactivate("pa") MouseClick($Primary, 160,140, 2, 0) sleep(20000) winactivate("pa") $vServerClip=clipget() $vServerString=stringsplit($vServerClip,@TAB) $vServer=$vServerString[22] Send("{F10}tf") Send($vServer) send("{TAB}a") Send("{ENTER}") sleep(1000) send("{ENTER}") sleep(300) endif endfunc [\code] Link to comment Share on other sites More sharing options... Valuater Posted February 24, 2006 Valuater MVPs 11.1k 7 Share Posted February 24, 2006 8) Link to comment Share on other sites More sharing options... cdkid Posted February 24, 2006 cdkid Active Members 715 El Spamino Share Posted February 24, 2006 /me is probably way off-base but in ur loop try if @error <> 0 then continueloop AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide! Link to comment Share on other sites More sharing options...
Josbe Posted February 24, 2006 Share Posted February 24, 2006 /me is probably way off-base but in ur loop try if @error <> 0 then continueloopYep, probably he/she needs check if StringSplit() returns any array. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
monte Posted February 24, 2006 Author Share Posted February 24, 2006 sorry about the code: expandcollapse popup#include <GUIConstants.au3> #include <array.au3> #notrayicon $checkRun = "Emc Script" If WinExists($checkRun) Then Exit GUICreate("Emc Script", 350, 210) GUISetBkColor (0xA9A9A9) $button1 = GUICtrlCreateIcon ("C:\progra~1\pa.bmp",-1,10,10); pa GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $button1 pa() if @error then continueloop EndSelect WEnd func pa() seterror(1) If WinExists("pa") Then $vServerClip=clipget() $vServerString=stringsplit($vServerClip,@TAB) $vServer=$vServerString[22] WinActivate("pa") sleep(1000) Send("{F10}tf") Send($vServer) send("{TAB}a") Send("{ENTER}") sleep(1000) send("{ENTER}") else global $mycmd="C:\progra~1\citrix\icacli~1\pn.exe /pn:" & '"farm"' & ' /app:"pa Client"' Dim $primary Dim $secondary $k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons") If $k = 1 Then $primary = "right" $secondary = "left" else $primary = "left" $secondary = "right" endIf msgbox(1,"","Opening pa, please have your rsa token ready. If the server search does not commence upon entering, please reclick the pa icon.", 20) run($mycmd) WinWaitActive("pa") winactivate("pa") MouseClick($Primary, 160,140, 2, 0) sleep(20000) winactivate("pa") $vServerClip=clipget() $vServerString=stringsplit($vServerClip,@TAB) $vServer=$vServerString[22] Send("{F10}tf") Send($vServer) send("{TAB}a") Send("{ENTER}") sleep(1000) send("{ENTER}") sleep(300) endif endfunc Link to comment Share on other sites More sharing options...
Valuater Posted February 24, 2006 Share Posted February 24, 2006 (edited) you are trying to make a button with an icon... thats ok.. but $button1 = GUICtrlCreateIcon ("C:\progra~1\pa.bmp",-1,10,10); pa you are using a .bmp.... and i dont think that will work remove SetError(1) 8) Edited February 24, 2006 by Valuater Link to comment Share on other sites More sharing options...
GaryFrost Posted February 24, 2006 Share Posted February 24, 2006 (edited) try Edit: put another check on the array expandcollapse popup#include <GUIConstants.au3> #include <array.au3> #notrayicon $checkRun = "Emc Script" If WinExists($checkRun) Then Exit GUICreate("Emc Script", 350, 210) GUISetBkColor(0xA9A9A9) $button1 = GUICtrlCreatePic("C:\progra~1\pa.bmp", 10, 10); pa GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $button1 pa() EndSelect WEnd Func pa() If WinExists("pa") Then $vServerClip = ClipGet() $vServerString = StringSplit($vServerClip, @TAB) If IsArray($vServerString) Then If $vServerString[0] >= 22 Then $vServer = $vServerString[22] EndIf WinActivate("pa") Sleep(1000) Send("{F10}tf") Send($vServer) Send("{TAB}a") Send("{ENTER}") Sleep(1000) Send("{ENTER}") Else Global $mycmd = "C:\progra~1\citrix\icacli~1\pn.exe /pn:" & '"farm"' & ' /app:"pa Client"' Local $primary Local $secondary $k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons") If $k = 1 Then $primary = "right" $secondary = "left" Else $primary = "left" $secondary = "right" EndIf MsgBox(1, "", "Opening pa, please have your rsa token ready. If the server search does not commence upon entering, please reclick the pa icon.", 20) Run($mycmd) WinWaitActive("pa") WinActivate("pa") MouseClick($primary, 160, 140, 2, 0) Sleep(20000) WinActivate("pa") $vServerClip = ClipGet() $vServerString = StringSplit($vServerClip, @TAB) If IsArray($vServerString) Then If $vServerString[0] >= 22 Then $vServer = $vServerString[22] EndIf Send("{F10}tf") Send($vServer) Send("{TAB}a") Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(300) EndIf EndFunc ;==>pa Edited February 24, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
monte Posted February 24, 2006 Author Share Posted February 24, 2006 I've tried the following and my script failed when I didn't have the correct data in the clipboard. and stringsplit returns an array. Case $msg = $button1 privateArk() if @error <> 0 then continueloop I also tried removing seterror(1) and keeping both: if @error <> 0 then continueloop and if @error then continueloop both still crash script. Thanks for your help Link to comment Share on other sites More sharing options...
Josbe Posted February 24, 2006 Share Posted February 24, 2006 I've tried the following and my script failed when I didn't have the correct data in the clipboard. and stringsplit returns an array.Case $msg = $button1 privateArk() if @error <> 0 then continueloopI also tried removing seterror(1) and keeping both:if @error <> 0 then continueloopandif @error then continueloopboth still crash script. Thanks for your helpCheck the gafrost's suggestion. Maybe your problem is with StringSplit() output. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
monte Posted February 24, 2006 Author Share Posted February 24, 2006 Thank you guys for all your help (including girls if there were any). I created an if else ( If $vServerString[0] >= 22 Then ) within my original if else and removed my seterror and if @error. This works....I I don't know why I didn't think of it earlier. *duh* Thank you guys so much! You were a real help! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now