GLBasic forum

Main forum => Bug Reports => Topic started by: siatek on 2012-Nov-28

Title: variables
Post by: siatek on 2012-Nov-28
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
Title: Re: variables
Post by: mentalthink on 2012-Nov-28
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...
Title: Re: variables
Post by: siatek on 2012-Nov-29
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
Title: Re: variables
Post by: MrTAToad on 2012-Nov-29
It can get things a bit confused unfortunately...
Title: Re: variables
Post by: kanonet on 2012-Nov-29
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.
Title: Re: variables
Post by: siatek on 2012-Nov-29
mkey ... but im think that its strange becouse its function parametr

so i will do a some kind prefix for global variables ...
Title: Re: variables
Post by: kanonet on 2012-Nov-29
A function parameter is just a definition of a new local variable.  ;)
Title: variables
Post by: Kitty Hello on 2012-Nov-29
It should work though. It's a bug.