Jump to content
Sign in to follow this  
Wade

Large global array problem

Recommended Posts

Wade

I'm having problems with a large global array. Back in my main program, Ubound on the array is only 17 and the _ArrayDisplay function doesn't display anything at all.

I initialize it to 1 element, and in a function I populate it with around 12,000 rows of String data. Within that function, Ubound works and I even write the array to a file using Ubound and a For loop. No problems.

Immediately after returning to the main function, the array no longer works properly. I don't know what I'm doing wrong.

In the main program:

Global $aLog[1]

In the function, there are lots of these additions:

_ArrayAdd($aLog, $recv)

Also in the function, there is another call to write the array:

If $WRITE_FILE = True Then WriteArray($aLog)

That function is below:

Func WriteArray($array)

; Write a whole array to a text file

Local $filename = "QUEUES.txt"

Local $file = FileOpen($filename, 1)

Local $i

If $file = -1 Then

MsgBox(0,"ERROR","Couldn't open Queue output file '" & $filename & "' for writing.", 10)

Return

EndIf

; Loop through array.

For $i = 1 to UBound($array)-1

FileWrite($file, $array[$i] & @CRLF & @CRLF)

Next

FileClose($file)

EndFunc

Then back in the main program (after the above functions are called), immediately I try this:

MsgBox(0,"First uBound","First Ubound for aLog=" & Ubound($aLog))

_ArrayDisplay($aLog,"aLog")

And I get 17 (versus 12,000) and the Display never does anything at all.

Any ideas? I'm stuck. All help is appreciated! I also tried passing it in byref and also returning it from the Function, but I get the same results both ways.

Thanks,

Wade

Share this post


Link to post
Share on other sites
Wade

I just tried updating from version 3.2.0.1 to 3.2.4.9 and now it works even less than before. The file writing in the Function doesn't work, and the Ubound is now 1 instead of 17. The _ArrayDisplay does work though (only shows one element).

Wade

Share this post


Link to post
Share on other sites
Wade

I just tried updating from version 3.2.0.1 to 3.2.4.9 and now it works even less than before. The file writing in the Function doesn't work, and the Ubound is now 1 instead of 17. The _ArrayDisplay does work though (only shows one element).

Wade

It is working differently now because something has changed in the TCP routines (where the data is read from). I'll have to get that straightened out before I can see if the arrays work differently now.

Wade

Share this post


Link to post
Share on other sites
Wade

Okay, I needed to add BinarytoString around the TCP calls, that got me back to where I was before switching Autoit versions.

Wade

Share this post


Link to post
Share on other sites
Wade

I think I figured out the problem.

Wade

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  

×