Problem with types and DIMPUSH

Previous topic - Next topic

neseir

Hi

I'm struggling with adding new entries in an array of types. The compiler complains about the DIMPUSH statment in line 68 (marked with <=---) :

Code (glbasic) Select

// IDE Version: 10.113
// Tile
CONSTANT TS_FREE% = 0

// Brick
CONSTANT BS_NORMAL% = 0

TYPE TBrick
pX%; pY%
dX; dY
image%
status%

FUNCTION Init: aX%, aY%, aImage%
self.pX = aX
self.pY = aY
self.image = aImage
self.status = BS_NORMAL

self.dX = aX * 48
self.dY = aY * 48
ENDFUNCTION
ENDTYPE

//GLOBAL newBrick AS TBrick

TYPE TTile
pX; pY
status%

FUNCTION SetPosition : aX, aY
self.pX = aX
self.pY = aY
ENDFUNCTION

ENDTYPE

TYPE TGrid
width% ; height;
tiles[] AS TTile
bricks[] AS TBrick

FUNCTION SetSize : aWidth%, aHeight%
self.width = aWidth
self.height = aHeight
DIM self.tiles[aWidth][aHeight]
ENDFUNCTION

FUNCTION Init:
LOCAL iY%
LOCAL iX%
IF self.width > 0 AND self.height > 0
FOR iY = 0 TO self.height - 1
FOR iX = 0 TO self.width - 1
self.tiles[iX][iY].status = TS_FREE
NEXT
NEXT
ENDIF
ENDFUNCTION

FUNCTION AddBrick : aX%, aY%, aType%
IF aX < self.width AND aY < self.height
LOCAL newBrick AS TBrick
newBrick.Init(aX, aY, aType)
DIMPUSH bricks[], newBrick                             // <=-- "Wrong argument type"
ENDIF
ENDFUNCTION
ENDTYPE



MrTAToad

#1
Shouldn't it be :

Code (glbasic) Select
DIMPUSH self.bricks[], newBrick

Hence the error message ?

neseir

 :S of course!! Thanks, have forgot to add a couple of these after starting to use functions inside types. This time I were too focused on that I probably had messed up the type definition.