GLBasic forum

Main forum => GLBasic - en => Topic started by: bigsofty on 2012-Sep-17

Title: Prototype problems
Post by: bigsofty on 2012-Sep-17
PROTOTYPE is one of those commands I've barley used, I always seem to run into problems with trying to get them to do things that they dont want to do.  :S

This is probably another example but here goes...

As you can see by this code, I am trying to prototype a function within a type to another function within a type (I need the function to have access to .self) but that's a no-go with the compiler. Is it possible at all?

Here is my simple test code...

Code (glbasic) Select
PROTOTYPE update_proto:

TYPE tt

x#

update AS update_proto

FUNCTION SetUp:
// self.update = self.myupdate
ENDFUNCTION

FUNCTION myupdate:
self.x# = 1
ENDFUNCTION

ENDTYPE

GLOBAL t AS tt

t.SetUp()

t.update = t.myupdate

t.update()


Anyone see a way what I am doing wrong here?
Title: Re: Prototype problems
Post by: MrTAToad on 2012-Sep-17
PROTOTYPE can only be used with standard functions unfortunately - it wont (currently) work with the prototyped function being in an extended type.
Title: Re: Prototype problems
Post by: bigsofty on 2012-Sep-17
Bummer! I kind of thought that may be the problem but I just hoped my syntax was wrong.

Ah well, thanks for the heads up Mr T.