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?
two dimensional arrays
- gcsupport
- Posts: 21
- Joined: Mon Oct 07, 2013 8:15 pm
- jpratt
- Enovation Controls Development
- Posts: 222
- Joined: Mon Jun 21, 2010 11:18 am
Re: two dimensional arrays
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.
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
Software Development Manager
- young123
- Posts: 14
- Joined: Thu Jan 16, 2014 4:59 am
Re: two dimensional arrays
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...
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
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
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.
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.