[Gambas-user] ARRAYS - Filling with data

Emil Lenngren emil.lenngren at ...626...
Thu Jan 26 18:49:06 CET 2012


There is currently no simple way to assign values to a multi-dimensional
array.
The only way is to assign one element at a time:
arr[0, 1] = 3
arr[0, 2] = 4
and so on.
You can get around this by having a Integer[][] instead, or simply use a
single-dimensional array but do the position calculation yourself (index =
y*rowsize + x).

/Emil

2012/1/26 Jussi Lahtinen <jussi.lahtinen at ...626...>

> For some reason this post didn't appear to my email, it's only visible in
> nabble ( http://old.nabble.com/gambas-user-f3427.html ).
> Anyone knows why?
>
>
> And the answer to the post, perhaps this way:
>
> DIM Walls AS NEW Integer[]
>
> Walls.Insert([38, 150, 38, 80, 38, 80, 180, 80, 180, 80, 180, 150, 180,
> 150, 38, 150])
> Walls.Insert([38, 112, 75, 112, 75, 112, 75, 80, 150, 80, 150, 107, 130,
> 80, 130, 107])
> Walls.Insert([108, 80, 108, 92, 90, 92, 110, 92, 110, 92, 110, 107, 110,
> 107, 180, 107])
> Walls.Insert([90, 80, 90, 92, 90, 112, 90, 150, 120, 150, 120, 118, 120,
> 118, 145, 118])
> Walls.Insert([145, 150, 145, 115, 145, 115, 180, 115])
>
> http://gambasdoc.org/help/comp/gb/integer%5B%5D/insert
>
> For 2D arrays, I don't know!
>
> Why you don't want to load the data from file?
> The file can be put inside the exec (/Data), so you don't have create
> separated file nor you have to extract it from there.
>
>
> Jussi
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list