GLBasic forum

Main forum => GLBasic - en => Topic started by: PeeJay on 2009-Jun-06

Title: Update problems
Post by: PeeJay on 2009-Jun-06
I've just updated from a (very!) old version, and have hit problems.

Gernot - you need to amend the help file - the example source for the PLAYMUSIC command doesn't include the loop parameter (which was the first thing to catch me out!)

However, I'm now getting an error in my high score loading routine, which has me beat. The error is:-

compiling:
C:\DOCUME~1\PeeJay\LOCALS~1\Temp\glbasic\gpc_temp0.cpp: In function `DGInt __GLBASIC__::LoadHiScores()':
C:\DOCUME~1\PeeJay\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:2171: error: invalid initialization of reference of type 'DGNat&' from expression of type 'DGInt'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:864: error: in passing argument 2 of `void __GLBASIC__::READBYTE(DGNat, DGNat&)'
C:\DOCUME~1\PeeJay\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:2179: error: invalid initialization of reference of type 'DGNat&' from expression of type 'DGInt'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:864: error: in passing argument 2 of `void __GLBASIC__::READBYTE(DGNat, DGNat&)'
*** FATAL ERROR - Please post this output in the forum

and the function is:-

Code (glbasic) Select
FUNCTION LoadHiScores:

LOCAL loop,loop1,byte,bytes$=""

LOCAL check=OPENFILE(0,"hiscore.dat",TRUE)

IF check=FALSE
FOR loop=0 TO 4
hiscore$[loop][1]=75000-(loop*5000)
NEXT
hiscore$[0][0]="FIRST NAME"
hiscore$[1][0]="SECOND NAME"
hiscore$[2][0]="THIRD NAME"
hiscore$[3][0]="FOURTH NAME"
hiscore$[4][0]="FIFTH NAME"
ELSE
FOR loop=0 TO 4
FOR loop1=0 TO 19
READBYTE 0,byte
byte=byte+20
bytes$=bytes$+CHR$(byte)
NEXT
hiscore$[loop][0]=bytes$
bytes$=""
FOR loop1=0 TO 6
READBYTE 0,byte
byte=byte+20
bytes$=bytes$+CHR$(byte)
NEXT
hiscore$[loop][1]=bytes$
bytes$=""
NEXT
ENDIF

CLOSEFILE 0

ENDFUNCTION


It compiled perfectly before, so obviously something has changed since my previous version. Any pointers anyone? Thanks
Title: Re: Update problems
Post by: Hemlos on 2009-Jun-06
byte% was the culprit.
initialally declaring the local byte% was all that is needed....

Code (glbasic) Select
FUNCTION LoadHiScores:

LOCAL loop,loop1,byte%,bytes$=""

LOCAL check=OPENFILE(0,"hiscore.dat",TRUE)

IF check=FALSE
FOR loop=0 TO 4
hiscore$[loop][1]=75000-(loop*5000)
NEXT
hiscore$[0][0]="FIRST NAME"
hiscore$[1][0]="SECOND NAME"
hiscore$[2][0]="THIRD NAME"
hiscore$[3][0]="FOURTH NAME"
hiscore$[4][0]="FIFTH NAME"
ELSE
FOR loop=0 TO 4
FOR loop1=0 TO 19
READBYTE 0,byte
byte=byte+20
bytes$=bytes$+CHR$(byte)
NEXT
hiscore$[loop][0]=bytes$
bytes$=""
FOR loop1=0 TO 6
READBYTE 0,byte
byte=byte+20
bytes$=bytes$+CHR$(byte)
NEXT
hiscore$[loop][1]=bytes$
bytes$=""
NEXT
ENDIF

CLOSEFILE 0

ENDFUNCTION
Title: Re: Update problems
Post by: PeeJay on 2009-Jun-06
ah, stupid me! Many thanks for that ..... I guess that means I've got no more excuses not to get this game finished then! (it's only 10 months behind schedule =D)
Title: Re: Update problems
Post by: Hemlos on 2009-Jun-06
Awesome, glad to be of help.  :good:

Hope to see your new game soon, whatchamacallit?
Title: Re: Update problems
Post by: PeeJay on 2009-Jun-06
It's TriTangle - there are screenies on my site - the game is pretty much finished (and has been for literally months) - I just need to sort out the audio side of things .....