Author Topic: Multi Dimensional Arrays  (Read 663 times)

0 Members and 1 Guest are viewing this topic.

Offline UPNPAD

  • Major(1)
  • Posts: 36
Multi Dimensional Arrays
« on: January 18, 2008, 06:35:27 am »
Hey I'm having trouble using multi-dimensional arrays in my script, an error comes "[Error] (9:26): Close block(']') expected". Here's the first 10 lines from the script.

Code: [Select]
const
  Colour = $FF52DD52;

var
  i: integer;
  n: integer;
  MaxNades: integer;
  nadeclasses: array[1..6,1..32] of integer;
 
function minutes(Ticks: integer; Custom: integer): boolean;

So ya, in the first place, can you use more than 1D arrays with this scripting engine? Thanks :)

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: Multi Dimensional Arrays
« Reply #1 on: January 18, 2008, 07:23:52 am »
do this:

Code: [Select]
var nadeclasses: array[1..6] of array[1..32] of integer;
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Multi Dimensional Arrays
« Reply #2 on: January 18, 2008, 08:24:32 am »
And to access the variable, you must access it as if it were an array of an array, not a multidimensional array so like nadeclasses[1][32] := 64; for example

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Multi Dimensional Arrays
« Reply #3 on: January 18, 2008, 12:43:44 pm »
wouldn't an:
  array[1..10] of array[1..10] of array[1..10] of vartype;
make 1000 array variables? O.o that would sure be interesting...
« Last Edit: January 18, 2008, 12:45:34 pm by Kavukamari »
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline UPNPAD

  • Major(1)
  • Posts: 36
Re: Multi Dimensional Arrays
« Reply #4 on: January 18, 2008, 09:39:42 pm »
Oh thanks everyone ;)