Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / Shouldn't array.length always return the length of an array?

Author
Message
BHoltzman
17
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 13th Sep 2019 04:34 Edited at: 13th Sep 2019 04:57
I'm not sure why the Img array length is undefined here? Shouldn't it be defined? I also see that Jwls.length is undefined. This behavior seems strange or wrong to me. Is it a bug, or am I misunderstanding how the language works?



The reason I think there should be a length is because of the documentation shown below which I'm assuming is true for AppGameKit Studio as well.



Interestingly if I put the following code into the main do loop:

print( img.length )
print( Jwls.length )

it prints 5 and 8.

This seems broken as well. Img should be 5, but Jwls was defined as [8, 8]. Shouldn't the array length be 64?

Attachments

Login to view attachments
Scraggle
Moderator
16
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Sep 2019 07:36
The “invalid expression “ thing does look like a Studio bug to me.
However,the length of jwls is correct. You can ask for the length of each 2nd dimension with jwls[var].length
blink0k
AGK Developer
7
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Sep 2019 08:26
Debug has never been able to display the .length property of an array.
Doesn't work in classic either.
Would be nice though
tiresius
17
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 13th Sep 2019 12:29
Debugging workaround is to keep assigning it to a dummy variable that you do track.

Probably because it's not a real "variable" but interpreter really just makes function calls to retrieve?
All conjecture.
Conjured Entertainment
AGK Developer
14
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 13th Sep 2019 12:49 Edited at: 13th Sep 2019 13:02
Shouldn't the i in img in line 41 be in caps ...Img ?

Better yet, change one of them to lower case in declaration to avoid the confusion with the array and Jwls type ?

Even if the compiler doesn't get confused, Earthlings will.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
BHoltzman
17
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 14th Sep 2019 00:12
Thanks for confirming the bug. I've reported it on GitHub.

Login to post a reply

Server time is: 2020-04-05 20:47:00
Your offset time is: 2020-04-05 20:47:00