Author Topic: Problem with types and DIMPUSH  (Read 981 times)

Offline neseir

  • Mc. Print
  • *
  • Posts: 21
    • View Profile
Problem with types and DIMPUSH
« on: 2011-Sep-20 »
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

  • Guest
Re: Problem with types and DIMPUSH
« Reply #1 on: 2011-Sep-20 »
Shouldn't it be :

Code: (glbasic) [Select]
DIMPUSH self.bricks[], newBrick
Hence the error message ?
« Last Edit: 2011-Sep-20 by MrTAToad »

Offline neseir

  • Mc. Print
  • *
  • Posts: 21
    • View Profile
Re: Problem with types and DIMPUSH
« Reply #2 on: 2011-Sep-20 »
 :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.