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 <=---) :
// 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
Shouldn't it be :
DIMPUSH self.bricks[], newBrick
Hence the error message ?
: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.