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 / Question about Arrays

Author
Message
Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 18th Mar 2012 16:58 Edited at: 18th Mar 2012 17:03
I want to make a grid like this


I define it like this:
Dim PositionsFields[10,10] as integer = [0,99,98,97,96,95,94,93,92,91,65,64,37,38,39,40,41,42,43,90,66,63,36,35,34,33,32,31,44,89,67,62,17,16,5,6,7,30,45,88,68,61,18,15,4,3,8,29,46,87,69,60,19,14,1,2,9,28,47,86,70,59,20,13,12,11,10,27,48,85,71,58,21,22,23,24,25,26,49,84,72,57,56,55,54,53,52,51,50,83,73,74,75,76,77,78,79,80,81,82]

But if I do this
Print(PositionsFields[1,1]) it only prints 0 when it should print 64

What I'm doing wrong?

iOS Apps from Trisect Development.
Click here.
Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 18th Mar 2012 21:16
Come on guys!
I'm stuck here.

iOS Apps from Trisect Development.
Click here.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 18th Mar 2012 21:19
you assigned the array wrong
=[[#,#,#,#,...],[#,#,#,#,...],[#,#,#,#,...]....]]

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps.
Developed the tiled map engine seen on the showcase.
Veterian for the military.
Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 18th Mar 2012 21:26 Edited at: 18th Mar 2012 21:41
I tried that but it still wont work

iOS Apps from Trisect Development.
Click here.
Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 18th Mar 2012 21:33
Okay now I tried this



I still get zero if i try this


iOS Apps from Trisect Development.
Click here.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 19th Mar 2012 00:44
You can't actually assign a multiple dimensions array in one line by this way.
Only for one dimension (a simple list).

So you will have to loop through each row and column to populate your array.
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 19th Mar 2012 00:49 Edited at: 19th Mar 2012 00:55
I guess my way is c++ and he is doing it teir one, which does not work for assigning arrays like c++. oh my bad it is not [ it is {. your first post confused me.


Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps.
Developed the tiled map engine seen on the showcase.
Veterian for the military.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 19th Mar 2012 00:50
Yes .. Tier2 is also here due to the Tier1's limitations.
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 1st Apr 2012 20:12
The Tier 1 initialisation of array data is very basic, and will only provide a single dimensional array with data. For more than one dimension, I suggest a function or subroutine to fill the data at run-time, or use a text file to import the data.

I drink tea, and in my spare time I write software.

Login to post a reply

Server time is: 2024-05-03 19:32:45
Your offset time is: 2024-05-03 19:32:45