News:

*NEW* Current Version on STEAM16.793

Webchat:
Visit the chat



Self

Previous topic - Next topic

MrTAToad

I noticed in the latest update that self isn't needed when accessing other extended types, so :

Code (glbasic) Select
TYPE Tb
FUNCTION go%:
DEBUG "here"
ENDFUNCTION
ENDTYPE

TYPE Ta
a%
z AS Tb
FUNCTION moo%:
z.go()
ENDFUNCTION
ENDTYPE

LOCAL p AS Ta

p.moo()

compiles and runs fine.  However, trying to do anything with a% without using self and there is a compiler error...

Kitty Hello

uh huh.
Does it work with self.foo()? If so, I'd stay that way. It's safer for future updates.
Otherwise, if you have a global function "foo", how would I know which one to call?

MrTAToad

Functions called within the same type need Self :

Code (glbasic) Select
FUNCTION test%:
moo()
ENDFUNCTION


wont compile.

Using :

Code (glbasic) Select
self.z.go()

works fine