GC compiler terminal: "Error: Variable xxx was not explicitly declared. "
This text added to my confusion saying that bytes shouldn't need dimensioning(?):
"Byte variables do not need any special commands to set them up - just put the name of the variable in to the command where the variable is needed.
Other types of variable can be used in a very similar way, except that they must be "dimensioned" first. This involves using the DIM command, to tell GCBASIC that it is dealing with something other than a byte variable." https://gcbasic.sourceforge.io/help/_variable_types.html
I now realise that this has changed with #OPTION EXPLICIT.
Maybe the quoted text needs editing or am I misunderstanding things?
Last edit: Roger Jönsson 2025-03-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have updated the Help. You point is valid and the Help needed updating.
Using Variables
Byte variables do not need any special commands to set them up - just put the name of the variable in to the command where the variable is needed. However, it is good practice to "dimension" all byte variables and to use #OPTION EXPLICiT. #OPTION EXPLICiT mandates the "dimensioning" of all variables in the user program. Using #OPTION EXPLICiT will improve the quality of the program.
Other types of variable can be used in a very similar way, except that they must be "dimensioned" first. This involves using the DIM command, to tell GCBASIC that it is dealing with something other than a byte variable.
A key feature of variables is that it is possible the have the microcontroller check a variable, and only run a section of code if it is a given value. This can be done with the IF command.
Number Variables
You can assign values to number variables using =.
A simple, but typical example follows. This is the typical for numeric variable assignment.
GC compiler terminal: "Error: Variable xxx was not explicitly declared. "
This text added to my confusion saying that bytes shouldn't need dimensioning(?):
"Byte variables do not need any special commands to set them up - just put the name of the variable in to the command where the variable is needed.
Other types of variable can be used in a very similar way, except that they must be "dimensioned" first. This involves using the DIM command, to tell GCBASIC that it is dealing with something other than a byte variable."
https://gcbasic.sourceforge.io/help/_variable_types.html
I now realise that this has changed with #OPTION EXPLICIT.
Maybe the quoted text needs editing or am I misunderstanding things?
Last edit: Roger Jönsson 2025-03-08
@Roger.
I have updated the Help. You point is valid and the Help needed updating.
Using Variables
Byte variables do not need any special commands to set them up - just put the name of the variable in to the command where the variable is needed. However, it is good practice to "dimension" all byte variables and to use
#OPTION EXPLICiT
.#OPTION EXPLICiT
mandates the "dimensioning" of all variables in the user program. Using#OPTION EXPLICiT
will improve the quality of the program.Other types of variable can be used in a very similar way, except that they must be "dimensioned" first. This involves using the DIM command, to tell GCBASIC that it is dealing with something other than a byte variable.
A key feature of variables is that it is possible the have the microcontroller check a variable, and only run a section of code if it is a given value. This can be done with the IF command.
Number Variables
You can assign values to number variables using
=
.A simple, but typical example follows. This is the typical for numeric variable assignment.
The actual source is here: https://github.com/GreatCowBASIC/Help/blob/main/source/variables.adoc
Evan