Complete Noob basic question

Previous topic - Next topic

nadthevlad

I am working through the help files and keep having troubles with building the projects.
I am typing in the tutorials word for  word but keep getting the same error where the variable is not explicitly defined


Code (glbasic) Select

LET a$="My"
LET b$="favourite number: "
LET c= 7

LET c$=a$ + " " + b$ + " : " + c

PRINT c$,0,20

SHOWSCREEN




Output
Code (glbasic) Select
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.10.074 SN:6756c99f - 2D, WIN32
"tut3.gbas"(21) warning : probably unassigned variable : a$
"tut3.gbas"(21) warning : probably unassigned variable : b$
"tut3.gbas"(21) warning : probably unassigned variable : c
"tut3.gbas"(23) warning : probably unassigned variable : c$
"tut3.gbas"(21) error : variable is not explicitly defined : a$


Can't figure out where I am going wrong.  Any help would be appreciated.

Running windows 7 64 bit.



kanonet

Welcome in the Forum nadthevlad

1. LET ist very, very outdated dont use it.

2. Explicit declaration is on. This means you are forced to either use LOCAL or GLOBAL (or constant) to define a variable. Look for these both commands in the manual, to see which one you need.
Or go to Project->Options and deselect explicit declaration, in this case all variables are automatic defined as global if you dont define them. But i recommend to all ways define variables by yourself, so you know what is happening. And i recommend to keep explicit declaration enabled, so you are always forced to define variables before you use them, so you can easier find misspelled ones.

BTW: the manual is really old and outdated in some parts... e.g. now there 3 types of variables: strings (a$), integer (a%) and floats (a# or just a) if you dont select a type its always a float, integer are fast, so use integer, if possible.

There is a GLB wiki, that you can check, there are tutorials too (most is the same like the manual -> outdated, but some new+nice parts are there): http://wiki.just-do-i-t.com/index.php?title=GLBasic_Wiki

Feel free to ask any question that you may have.

Regards.

EDIT: darn monono was faster. :O
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

nadthevlad

Thanks for the quick replies. 
I've got it now.