Jump to content

End Func issue


erezlevi
 Share

Recommended Posts

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

you 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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...