GLBasic forum

Main forum => GLBasic - en => Topic started by: Jonás Perusquía on 2012-Apr-10

Title: Cant find errors in my code
Post by: Jonás Perusquía on 2012-Apr-10
I can´t find the errors in my code... can you please help me?

Code (glbasic) Select
// ***** Included Source File *****
GETFONTSIZE 30,30
PRINT 100,200, "Presiona una tecla para comenzar"
KEYWAIT
CLEARSCREEN
GETFONTSIZE 28,28
RGB (255,0,0)
PRINT "Bienvenido aventurero! Dime, ¿Cual es tu nombre?", 100,100
INPUT varnombre$, 100,104
PRINT "Excelente! Bienvenido a PRUEBA " + varnombre$, 100, 108
KEYWAIT
CLEARSCREEN
PRINT "Estas solo en tu casa, ¿Que deseas hacer?", 100, 50
PRINT "a) Comer palomitas", 100, 55
PRINT "b) Bailar", 100, 60
PRINT "c) Salir del juego", 100, 65
a$= "a"
b$= "b"
c$= "c"
INPUT x$, 100, 70
IF x$ = a$ THEN PRINT "*Chomp, chomp, chomp*",100, 79
INPUT x$, 100, 70
IF x$ = b$ THEN PRINT "*zap, zappa, zap*", 100, 85
INPUT x$, 100, 70
IF x$ = c$ THEN CLEARSCREEN
PRINT "Estas a punto de salir de PRUEBA", 100, 100
KEYWAIT
CLEARSCREEN
END
Title: Re: Cant find errors in my code
Post by: r0ber7 on 2012-Apr-10
Did you get a compiler error? What did it say? Can't find anything wrong with the code at first glance.
Title: Re: Cant find errors in my code
Post by: Minion on 2012-Apr-10
There is a lone "RGB (255,0,0)" after GETFONTSIZE. Is that causing the problem ?
Title: Re: Cant find errors in my code
Post by: Jonás Perusquía on 2012-Apr-10
These are the errors i am getting:

Code (glbasic) Select
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:71fa70a5 - 3D, NET
"Ditrabox.gbas"(9) warning : probably unassigned variable : varnombre$
"Ditrabox.gbas"(20) warning : probably unassigned variable : x$
"Ditrabox.gbas"(9) error : variable is not explicitly defined : varnombre$
Title: Re: Cant find errors in my code
Post by: Minion on 2012-Apr-10
All this means is that the variables have not been defined before use. You can either declare them explicitly (Good move) or go into Project>Options and set the tick box for Explicity Declarations too off (Bad move)
Title: Re: Cant find errors in my code
Post by: spicypixel on 2012-Apr-10
Yep set either LOCAL varnombre$, x$ or GLOBAL varnombre$, x$ before referencing the variables ;)
Title: Re: Cant find errors in my code
Post by: Slydog on 2012-Apr-10
It would be handy if GLBasic included an error (or warning) number/id with each error.
You could use this to search the forums to find possible solutions, or to better understand the error.

And/or have the error include an optional link to a help file listing about the error and what are common causes, or link to a web page with that info.

Eg:
Code (glbasic) Select
"Ditrabox.gbas"(9) error [#12345] : variable is not explicitly defined : varnombre$
Title: Re: Cant find errors in my code
Post by: Kitty Hello on 2012-Apr-12
good idea. Will add that.
Title: Re: Cant find errors in my code
Post by: Jonás Perusquía on 2012-Apr-23
for a faster test, i disabled explicit variables, but at compiling it says:
Code (glbasic) Select

_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:71fa70a5 - 3D, NET
"Ditrabox.gbas"(8) warning : probably unassigned variable : varnombre$
"Ditrabox.gbas"(19) warning : probably unassigned variable : x$
Wordcount:30 commands
compiling:
C:\Users\JonasPm\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\JonasPm\AppData\Local\Temp\glbasic\gpc_temp0.cpp:24: error: no matching function for call to `GETFONTSIZE(int, int)'
C:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:1323: note: candidates are: void __GLBASIC__::GETFONTSIZE(DGInt&, DGInt&)
C:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:1324: note:                 void __GLBASIC__::GETFONTSIZE(DGNat&, DGNat&)
C:\Users\JonasPm\AppData\Local\Temp\glbasic\gpc_temp0.cpp:40: error: no matching function for call to `GETFONTSIZE(int, int)'
C:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:1323: note: candidates are: void __GLBASIC__::GETFONTSIZE(DGInt&, DGInt&)
C:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:1324: note:                 void __GLBASIC__::GETFONTSIZE(DGNat&, DGNat&)
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 1.5 sec. Time: 15:45
Build: 0 succeeded.
*** 1 FAILED ***

it does display an error... maybe there´s a problem with the directory where the project is located?
Title: Re: Cant find errors in my code
Post by: Slydog on 2012-Apr-24
Your problems are these lines:
Code (glbasic) Select
GETFONTSIZE 30,30
// and
GETFONTSIZE 28,28


The'GETFONTSIZE()' command expects two integer variables, and you're providing constants.
The command is for retrieving the current font size, you can't pass it numerical constants.
This is how you use it:
Code (glbasic) Select
LOCAL size_x%, size_y%
GETFONTSIZE size_x, size_y
DEBUG "The current font size is: " + size_x + " x " + size_y + "\n"
Title: Re: Cant find errors in my code
Post by: Jonás Perusquía on 2012-Apr-24
Slydog... YOU´RE MY HERO!!

i deleted the GETFONTSIZE since i though they would change the font size...

now i can compile and my project seems to be working now...

looks like its more complicated than i though but maybe in about a month i can create an interesting game :D
Title: Re: Cant find errors in my code
Post by: Kitty Hello on 2012-Sep-05
OK, GLB V11 will have GPCxxxx error numbers printed out.