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 Classic Chat / [BUG] AGK v2 increasing the size of an array

Author
Message
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 3rd Feb 2015 23:46
Increasing the size of an array works OK if you do this:


But this fails:


It's an easy enough work-around but it would be nice to have both methods work without error.

AGK V2 user - Tier 1 & 2
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Feb 2015 07:08
That is as I would expect it and it is not a bug.

In is an unusual use of the 'inc' command. The command is expected to be used against a numeric variable.

The '.length' of an array is not a normal variable. It is a special object associated with the array that the compiler treats differently. The command to grow or resize an array by changing this value is a special case.

I don't think I know of any language that uses the array.length type object/construct that would allow you to use it with an inc command.

(Usual disclaimer, I didn't create this language or compiler. Maybe the developers of this combination did mean to allow that and didn't code for it. But I have my doubts about that.)

Cheers,
Ancient Lady
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 4th Feb 2015 09:11
inc is for atomic variables that do not have side effects.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Feb 2015 10:04 Edited at: 4th Feb 2015 10:05
because basic use only integer and float i would expect inc works with this array syntax too.
its more a missing feature.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 4th Feb 2015 10:12
Yes, "missing feature" is a better description. I wasn't happy calling at a bug as nothing is broken but regardless of how things behave in the background, the average user would expect to be able to use INC in this way.

AGK V2 user - Tier 1 & 2
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Feb 2015 10:31 Edited at: 4th Feb 2015 10:31
yo,
btw instead of inc or a=a+1
you can use also this syntax
myArray.insert(1)

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-05-26 08:41:31
Your offset time is: 2024-05-26 08:41:31