erezlevi Posted September 30, 2009 Share Posted September 30, 2009 hi, is there a way to do something like: while true call ("function") wend func function() if @error then [b]exitfunction[/b] endfunc so that the while will restart all over with calling the function again? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2009 Moderators Share Posted September 30, 2009 erezlevi, This should do what you want: Global $fFlag While $fFlag = True function() If $fFlag = True Then ExitLoop ; if no error, exit loop - otherwise run function again WEnd Func function() ; Function code If @error Then $fFlag = False Return EndIf ; More function code if needed EndFunc M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
erezlevi Posted September 30, 2009 Author Share Posted September 30, 2009 not working. I think there is an issue with Array: C:\My Documents\bezeq MGMT test\199-cm\new01-09-09\real-time-ibmcc_DebugIt.au3 (1921) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $trim1 = $EREZ[$s1 + 4] $trim1 = ^ ERROR this gives an error but the next line is doesn't work. If @error Then Return EndIf Link to comment Share on other sites More sharing options...
erezlevi Posted September 30, 2009 Author Share Posted September 30, 2009 I can solve it using Mathematics: with the Ubound function, but I was wondering if there is a built in error machenism for Array dimension errors. If I am trying to reach the Array where there are no values or the dimensions is lower, then error reloop. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2009 Moderators Share Posted September 30, 2009 erezlevi, Why not post your full code so we can see why you are getting the array error. Then we will not waste time solving badly-explained problems with snippets of code. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
erezlevi Posted September 30, 2009 Author Share Posted September 30, 2009 erezlevi,Why not post your full code so we can see why you are getting the array error. Then we will not waste time solving badly-explained problems with snippets of code. M23you won't understand my code it is too long and complicated. you can create your own code using Array. create two files one with 10 lines and later one - another with 5 lines.use _filereadtoarray command and put those 10 lines in the array, then try to get the information from line 8 when you change the file to 5 lines while it is looping around using windows copy and paste use the file with 5 lines instead the 10 lines (overwrite the old one) your code will get stuck.my question is a more general one, I can solve the issue using Ubound, I want to know if there is a built in function. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2009 Moderators Share Posted September 30, 2009 erezlevi ,Well, I hope my answer is not too long and complicated. You have do this sort of errorchecking yourself. AutoIt can only do what you tell it - it cannot read your mind.If you create an array, it is up to you to make sure that you do not try to read outside the declared elements. You can use UBound (as you have already discovered) but many AutoIt functions return the size of the array in [0] element (_FileReadToArray is a good example) and you can use this directly to prevent errors.There will not then be a problem with "windows copy and paste". If you read in the new file with only 5 lines, _FileReadToArray will automatically reset the [0] element for you - just make sure that you never try to read a line over that maximum value and you should never have a problem. I hope this helps.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
martin Posted September 30, 2009 Share Posted September 30, 2009 not working. I think there is an issue with Array: C:\My Documents\bezeq MGMT test\199-cm\new01-09-09\real-time-ibmcc_DebugIt.au3 (1921) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $trim1 = $EREZ[$s1 + 4] $trim1 = ^ ERROR this gives an error but the next line is doesn't work. If @error Then Return EndIf real-time-ibmcc_DebugIt.au3? Is that anything to do with a debugger? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
erezlevi Posted September 30, 2009 Author Share Posted September 30, 2009 real-time-ibmcc_DebugIt.au3? Is that anything to do with a debugger? Hi martin, long time no seen..... (ever since the window messages stuff) the issue is that I am using TCP/IP connection to a machine and gets its value using TCPrecv. when the data is collected using TCPrecv (in var $m) I write it down to a file (the only way to do it!) using : $J=fileopen ("c:\test.txt",2) filewrite($J,$m) fileclose ($J). now the file contains the $m output. this output needs to be inserted to an Array in order to do string stuff, so the output will be better. if the TCP/IP connection is broken then the file test.txt contains lower line numbers, but the _filereadtoarray is working fine, but in the program I go: $s=$Array[80] but the file now only contains 20 lines. so the Au3 will fail and exit the code with a "Array variable has incorrect number of subscripts or subscript dimension range exceeded" - which is correct. I looked for @error in $s=$Array[80] but there is none I guess (Maybe developers can think about it), I solve the issue using Ubound, because I know more or less that the Array should be something in between 30 to 100 lines, and when loosing connection (TCP/IP) the file contains more or less 20 lines. 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