Call to undefined function

Previous topic - Next topic

shadok85

Hi there,
I'm new to GLBasic and, for learning purpose, I'm converting a BlitzMax sample into GLB. I have 2 files in the project:

Main Document (ComeAndGetMe.gbas):

Code (glbasic) Select

LOCAL UPDATE_FREQUENCY# = 100
LOCAL SPIKE_SUPPRESSION% = 20

GLOBAL gameTime AS TFRLTimer
gameTime.TFRLTimer_init(UPDATE_FREQUENCY#, SPIKE_SUPPRESSION%)

// the main loop starts here
WHILE TRUE
CLEARSCREEN

code...

SHOWSCREEN
WEND



and the TFRLTimer.gbas file which is:

Code (glbasic) Select

//==============================================================
//===FIXED RATE LOGIC  TWEEN  DELTA SPIKE SUPPRESSION (DSS)===
//==============================================================

TYPE TFRLTimer
newTime#
oldTime#
delta#

dssOn% // do we use delta spike suppression?
dssIndex% // index into DSS_Array where NEXT delta value is written
dssArray#[] // this array contains the delta values TO smooth
dssLenArray%         // how big is the array of delta values

logicFPS#
accumulator#
tween#

fpsAccumulator#
updateCount%
renderCount%
updatesPerSecond%
rendersPerSecond%

FUNCTION TFRLTimer_init: logicCyclesPerSec#, numSamples% = 0
self.logicFPS# = 1.0 / logicCyclesPerSec#
IF numSamples%
self.dssOn% = TRUE
DIM self.dssArray#[numSamples%]
self.dssLenArray# = numSamples%
ENDIF
ENDFUNCTION

FUNCTION TFRLTimer_processTime#:
self.newTime# = GETTIMERALL()
self.delta# = (self.newTime# - self.oldTime#) * 0.001
self.oldTime# = self.newTime#

IF self.dssOn% = TRUE
self.dssArray[self.dssIndex%] = self.delta#

LOCAL smoothDelta# = 0

FOR i% = 0 TO self.dssLenArray% - 1
smoothDelta# = smoothDelta# + self.dssArray[i%]
NEXT
self.delta# = smoothDelta# / self.dssLenArray%

self.dssIndex% = self.dssIndex% + 1
IF self.dssIndex% > self.dssLenArray% - 1 THEN self.dssIndex% = 0
ENDIF

self.accumulator# = self.accumulator# + self.delta#

self.fpsAccumulator# = self.fpsAccumulator# + self.delta#
IF self.fpsAccumulator# > 1.0
self.fpsAccumulator# = self.fpsAccumulator# - 1.0
self.updatesPerSecond% = self.updateCount%
self.updateCount% = 0
self.rendersPerSecond% = self.renderCount%
self.renderCount% = 0
ENDIF

RETURN self.delta#
ENDFUNCTION


FUNCTION TFRLTimer_logicUpdateRequired%:
IF self.accumulator# > self.logicFPS#
self.updateCount% = self.updateCount% + 1
self.accumulator# = self.accumulator# - self.logicFPS#
RETURN TRUE
ENDIF
RETURN FALSE
ENDFUNCTION


FUNCTION TFRLTimer_getLogicFPS#:
RETURN self.logicFPS#
ENDFUNCTION


FUNCTION TFRLTimer_getTween#:
self.renderCount% = self.renderCount% +1
RETURN self.accumulator# / self.logicFPS#
ENDFUNCTION


FUNCTION TFRLTimer_showSpikeSuppression: x%, y%
PRINT "Delta Spike Suppressor:", x%, y%
FOR i% = 0 TO self.dssLenArray% - 1
PRINT self.dssArray%[i%], x%, y% + (i% + 1) * 20
NEXT
PRINT "Final Delta: " + self.delta#, x%, y% + (self.dssLenArray% + 1) * 20
ENDFUNCTION


FUNCTION TFRLTimer_showFPS: x%, y%, showUpdateFPS% = TRUE, showRenderFPS% = TRUE
LOCAL ty% = y%

IF showUpdateFPS
PRINT "Logic FPS:  " + self.updatesPerSecond%, x%, ty%
ty% = ty% + 20
ENDIF
IF showRenderFPS
PRINT "Render FPS: " + self.rendersPerSecond%, x%, ty%
ENDIF
ENDFUNCTION
ENDTYPE



When I compile the project, I got this error:

_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.6.973 SN:90c38d47 - 3D, NET
"ComeGetMe.gbas"(0) warning : note : TYPE TFRLTimer is not declared

"ComeGetMe.gbas"(5) error : call to undefined function : TFRLTimer

and I can't really get why I got this error! I use the beta version of GLB (8.036). Please help me!

Thanks all, Mimmo



MrTAToad

Thats because the previous had a limit to how the type could be accessed - try with the 8.054 update.

shadok85

Quote
Thats because the previous had a limit to how the type could be accessed - try with the 8.054 update.

Ok, I've done the upgrade to 8.054. The error message is gone, now there is a warning message:

"ComeGetMe.gbas"(0) warning : note : TYPE TFRLTimer is not declared

What does it mean?

Kitty Hello

It means, that the compiler at this point has no idea about what a "TFRLTimer" is.
I'll fix that warning soon, too.

shadok85

Quote
It means, that the compiler at this point has no idea about what a "TFRLTimer" is.

Funny, it's just right there =D

Quote
I'll fix that warning soon, too.

Ok, thanks Gernot.