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 / 2D arrays and data

Author
Message
Baldielocks
7
Years of Service
User Offline
Joined: 28th Mar 2017
Location: Grimsby, England
Posted: 28th Mar 2017 13:38
Hi folks, I`me new to appgamekit I`ve been looking through a few things, I used to program in basic back in the 80`s but there is something I need to do, but can`t find it or work it out.
I`m trying to get some data in to arrays but just can`t do it, in the old basic this is what I want to do:-

dim move (10,3)
for a= 1 to 10
for b=0 to 3
read move(a,b)
next b
next a

data 2,5,7,8,3,9,6,2,7,9,2,45,6,9,3 etc.

where move(1,0) would be 2 , move(1,1) would be 5 , move(1,2) = 7, move 1,3 = 8 move(2,3) = 2 , move(2,1) = 9

I also need 1D string array , bu that would just be reading strings in the same method as above but just one loop i presume

any help would be greatly appreciated.
cheers





Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Mar 2017 14:26 Edited at: 28th Mar 2017 14:28
you can read data from file and using array commands
https://www.appgamekit.com/documentation/guides/12_array_changes.htm
or call a function which set data into array at runtime.

CountStringTokens ( str, delimiters )
CountStringTokens2 ( str, delimiter )
GetStringToken ( str, delimiters, token )
GetStringToken2 ( str, delimiter, token )

old array style 1d with compile time data.
dim a [ 5 ] as integer = [ 10, 20, 30, 40, 50 ]
new style
myArray as integer[5] = [3,4,1,5,2,6]
AGK (Steam) V2017.02.28 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Mar 2017 14:57
For a multidimension array, do it the same way.
global array as integer[ 5, 5 ]
array[ 0, 0 ] = 1
array[ 0, 1 ] = 2
etc
(I don't think you can put data into the array at declaration.)
Signature removed by mod because it's larger than 600x120... please resize and try again.

Login to post a reply

Server time is: 2024-04-25 02:49:19
Your offset time is: 2024-04-25 02:49:19