Cant find errors in my code

Previous topic - Next topic

Jonás Perusquía

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
<HTML><BASIC><EC>
Be free and do good things

r0ber7

Did you get a compiler error? What did it say? Can't find anything wrong with the code at first glance.

Minion

There is a lone "RGB (255,0,0)" after GETFONTSIZE. Is that causing the problem ?

Jonás Perusquía

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$
<HTML><BASIC><EC>
Be free and do good things

Minion

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)

spicypixel

Yep set either LOCAL varnombre$, x$ or GLOBAL varnombre$, x$ before referencing the variables ;)
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Slydog

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$
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Kitty Hello

good idea. Will add that.

Jonás Perusquía

#8
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?
<HTML><BASIC><EC>
Be free and do good things

Slydog

#9
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"
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Jonás Perusquía

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
<HTML><BASIC><EC>
Be free and do good things

Kitty Hello

OK, GLB V11 will have GPCxxxx error numbers printed out.