It seems arrays have a limit Topic is solved

Report problems with documented functionality
david_ho
Posts: 1
Joined: 10 Mar 2022, 01:41

It seems arrays have a limit

10 Mar 2022, 01:48

Hi there,

I created an array := [123123@someemail.com , 1231241@someemail.com , ... ] that has about 187 items. I started running into issues. So, I msgboxed the array.length and was not getting any response. I cut the items down to 6, and got array.length is 6 in msgbox. So, I figured there is an array limit. I tried 149 items, and that worked. So, somewhere between 150 and 187 items there is a break down. Is this supposed to be the case? Does the array have a byte size limit? Or is there an item limit? I suppose I can test this out on my own, but also wondering if this is a bug.

Thanks
User avatar
lmstearn
Posts: 698
Joined: 11 Aug 2016, 02:32
Contact:

Re: It seems arrays have a limit

10 Mar 2022, 07:49

Hi, and welcome to Bug Reports. :|
Did you want the array elements in a string instead?

Code: Select all

 ["123123@someemail.com", "1231241@someemail.com", ... ] 
Else they are properties returning null from a null class, so expect weirdness.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
gregster
Posts: 9085
Joined: 30 Sep 2013, 06:48

Re: It seems arrays have a limit  Topic is solved

10 Mar 2022, 13:32

Afaik, this is not a bug, but AHK v1 has a fixed parser limit of 512 tokens for this kind of hardcoded expressions (AHK v2 now allows a lot more, I think, by allowing dynamic allocations):
lexikos wrote:
22 Jan 2018, 03:24
Be aware that there is currently a limit of 512 tokens per expression, where [, ], {, }, "item1", key1, : and , each count as one token. When you create large data structures with a single object literal, it is more likely you will encounter this limit.
I think you can work around this programmatically by doing something like this to concatenate arrays (also with more tokens than here):

Code: Select all

arr1 := [5, 6, 7, 8, 9]
arr2 := [1, 2, 3, 4, arr1*]

for index, value in arr2	
	msgbox % index " : " value
Or to insert an array at some position of another array:

Code: Select all

x1 := ["1", "4", "5"]
x2 := ["2", "3"]
x1.InsertAt(2, x2*)      ; insert at position 2
for index, value in x1	
	msgbox % index " : " value

Edit: and yes, lmstearn is of course right. Strings like email addresses should be quoted in expressions. Only pure numbers can be unquoted.
User avatar
Delta Pythagorean
Posts: 628
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: It seems arrays have a limit

10 Mar 2022, 17:03

Arrays don't have a .Length property but a .Length() method. There's also a .Count() and .MaxIndex().

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 21 guests