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 / Resizing multidimensional arrays

Author
Message
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Feb 2017 21:33 Edited at: 13th Feb 2017 21:35
Hi,
How can I resize multidimensional arrays?
The following example generates an error:
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Feb 2017 21:55
It's not something I've tried doing before but a quick test suggests that you need to set the length of each secondary element individually:

AGK V2 user - Tier 1 (mostly)
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Feb 2017 22:15
Thanks Scraggle for your tip, but I really cannot understand this approach.
How many lengths can have a 2-dimensional array? I thought it was only 2
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Feb 2017 22:27
So did I but this test proves that each secondary element can be a different length:
AGK V2 user - Tier 1 (mostly)
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Feb 2017 23:30 Edited at: 13th Feb 2017 23:45
Thank you very much. The snippet above makes things clearly.
The k refers to how many rows the matrix will have. In our case the



defines the array with 6 rows (5+1)
Afterwards, each row of the array can have different length. This is specified by the code line:



which, in your example, ranges from 1 to 5
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 14th Feb 2017 09:14
You can also dynamically add and remove elements to your array with .insert and .remove

Documentation is here

Login to post a reply

Server time is: 2024-09-29 23:29:04
Your offset time is: 2024-09-29 23:29:04