Sign in to follow this  
Followers 0
Gar

Array stops being an array?

5 posts in this topic

So I have a bit of complex code that runs normally for awhile, then, at some point, the array I'm using blanks to nothing. (just "" and not an array)

I have very few interactions with the array, so I can't figure out why this is happening. I have some _ArrayPops, but I put two 'null's at [0] and [1] and stop the pops if they are 'null'... but it's still happening. I also have some ByRefs passes.

Does anyone know if there's a common bug or something that can blank an array?

Share this post


Link to post
Share on other sites



Gar,

Arrays usually behave unless you remove all the elements (which you say you do not) or you redeclare them a a simple variable. If you posted your code we might be able to offer more pertinent advice. :unsure:

GEOSoft - look away now! :>

When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Gar,

Arrays usually behave unless you remove all the elements (which you say you do not) or you redeclare them a a simple variable. If you posted your code we might be able to offer more pertinent advice. :unsure:

GEOSoft - look away now! :>

When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code.

M23

Cool thanks for the tag info, am sort of newbie here.

This area MUST be the problem but I can't discern exactly how.

$Array = _ArrayCreate("Null", "Null")

;some other function adds elements to the array, then:

For $count = UBound($Array)-1 to 2 step -1
    If $Array[$count] = "Null" Then
        Return
    EndIf
    $event = _ArrayPop($Array)
Next

This eventually results in the array being popped to zero... but shouldn't this work?

Share this post


Link to post
Share on other sites

Gar,

- 1. Why use the UDF function when you can create arrays by merely declaring them? :unsure:

- 2. Return is for exiting functions - you need ExitLoop to escape from the For...Next loop. :D

- 3. If you stop your loop at 2 you will never check the Null values - remember that arrays start at element [0]. ;)

This should work for you: :>

#include <Array.au3>

Global $Array[2] = ["", ""]

;some other function adds elements to the array, then:

For $count = UBound($Array) - 1 To 1 Step -1
    If $Array[$count] = "" Then
        ExitLoop
    EndIf
    $event = _ArrayPop($Array)
Next

_ArrayDisplay($Array)

All clear? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Ah, thank you! A couple things I never knew :unsure: Thanks for the info, it worked!

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