I can´t find the errors in my code... can you please help me?
// ***** 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
Did you get a compiler error? What did it say? Can't find anything wrong with the code at first glance.
There is a lone "RGB (255,0,0)" after GETFONTSIZE. Is that causing the problem ?
These are the errors i am getting:
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$
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)
Yep set either LOCAL varnombre$, x$ or GLOBAL varnombre$, x$ before referencing the variables ;)
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:
"Ditrabox.gbas"(9) error [#12345] : variable is not explicitly defined : varnombre$
good idea. Will add that.
for a faster test, i disabled explicit variables, but at compiling it says:
_______________________________________
*** 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?
Your problems are these lines:
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:
LOCAL size_x%, size_y%
GETFONTSIZE size_x, size_y
DEBUG "The current font size is: " + size_x + " x " + size_y + "\n"
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
OK, GLB V11 will have GPCxxxx error numbers printed out.