two dimensional arrays

Discuss issues and ideas you have to configuring displays with PowerVision
gcsupport
Posts: 21
Joined: Mon Oct 07, 2013 8:15 pm

two dimensional arrays

Post by gcsupport » Thu Mar 06, 2014 12:46 pm

hi support

I defined a 2 dimensional array like this =>

uint [][] array1(55)(7);

But I get a compiler error =>

ERR: Expected ',' or ';'

Am I defining this wrongly or does the scripting function not support this?
jpratt
Enovation Controls Development
Enovation Controls Development
Posts: 222
Joined: Mon Jun 21, 2010 11:18 am

Re: two dimensional arrays

Post by jpratt » Tue Mar 11, 2014 9:53 am

I don't believe that our AngelScript implementation supports two dimensions.

You can find details on the angel script support on the "Script Syntax Reference" tab in scripting. We are working on some new features that will better support "tables" such as this but for now you will likely have to use parallels arrays.
Jake Pratt
Software Development Manager
young123
Posts: 14
Joined: Thu Jan 16, 2014 4:59 am

Re: two dimensional arrays

Post by young123 » Mon May 26, 2014 4:30 am

Hi,

Somehow angelscript does support two dimensional arrays !

I use one to navigate through a number of menus like this:

const int[][] navi =
{
// arrow keys actions <, >, Up, Down
{ 2, 1, -1, 10}, // 0 main help
{ 0, 2, -1, -1}, // 1 rear
{ 1, 0, -1, -1}, // 2 stat
{-1, -1, -1, -1}, // 3 not used
{-1, -1, -1, -1}, // 4 not used
{-1, -1, -1, -1}, // 5 not used
{-1, -1, -1, -1}, // 6 not used
{-1, -1, -1, -1}, // 7 not used
{-1, -1, -1, -1}, // 8 not used
{-1, -1, -1, -1}, // 9 not used
{17, 11, 0, -1}, // 10 main engine and vehicle speed
{10, 12, 0, -1}, // 11 transmission
{11, 13, 0, -1}, // 12 vehicle and body angle
{12, 14, 0, -1}, // 13 gauges fuel and temperature
{13, 15, 0, -1}, // 14 warning box
{14, 16, 0, -1}, // 15 warning and indicators
{15, 17, 0, -1}, // 16 maintenance
{16, 10, 0, -1}, // 17 time and date
};

In my case the first index corresponds to a page number.
The 4 numbers tell me to which menu page to navigate when one of the 4 arrow buttons is pressed.
Value =-1 means that using this button you can not go to another page.

To get a value out of the navi table I use for example :
int nextMenu;
nextMenu = navi[currentMenu][direction];

Hope this helps...
gcsupport
Posts: 21
Joined: Mon Oct 07, 2013 8:15 pm

Re: two dimensional arrays

Post by gcsupport » Mon May 26, 2014 9:28 am

A static allocation works fine. But I'll reduce code size by 90% if I can allocate memory dynamically.
CustomFP
Posts: 41
Joined: Thu Mar 22, 2012 4:12 pm

Re: two dimensional arrays

Post by CustomFP » Tue Jun 10, 2014 8:47 pm

While the memory will need to be allocated statically in the array definition, there is not issue changing the value of a cell later in the code.
2D arrays can also be split into a single dimension,
In the example above navi[2] = {1,0,-1,-1} and would be type int[].

It also looks like arrays have no problem being passed into and out of function.