variables

Previous topic - Next topic

siatek

ok i found a strange error i think

in my program i have a GLOBAL variable called tile

TYPE TTile
  width
  height
ENDTYPE

GLOBAL tile as TTile

i have also global variable game as TGame

the TGame TYPE has variable map as TMap
and in the TMap TYPE i have a function:

FUNCTION isCollisionTile: tile%

ENDFUNCTION

and GLBasic think's that the tile% is wrong and its thinking that this is my global tile variable ...

ufff

i think that this is a bug but maybe im wrong ?

regards
glbasic roxx !!!

mentalthink

I'm not sure but I think it's for the percent symbol...

FUNCTION isCollisionTile: tile%

ENDFUNCTION

try to put like this:
FUNCTION isCollisionTile: tile

ENDFUNCTION

I think it's this I remember in some program the problem was this... not sure 100 but I think it's this...

siatek

The only one working solution is when i change name "tile" to other for example

FUNCTION isCollisionTile: t
ENDFUNCTION

i think that in this version

FUNCTION isCollisionTile: tile
ENDFUNCTION

or

FUNCTION isCollisionTile: tile%
ENDFUNCTION

compiler thinks that this is global variable, but im think (maybe im wrong) that it shoudnt

cheers
glbasic roxx !!!

MrTAToad

It can get things a bit confused unfortunately...

kanonet

Its not a bug, you are just using it wrong.
You already defined a GLOBAL with the name tile. So you can nut define a 2nd variable with the name tile, you just get name collisions. And both are different var types so the compiler is very right to throw you an error. Thats why you should avoid GLOBALs (or at least dont give them short and obvious names) if you can.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

siatek

mkey ... but im think that its strange becouse its function parametr

so i will do a some kind prefix for global variables ...
glbasic roxx !!!

kanonet

A function parameter is just a definition of a new local variable.  ;)
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Kitty Hello

It should work though. It's a bug.