|
1.1 What is GS9 ?
To put it simple,
GS9
is a programming language.
But what is a programming language? A programming language is a language in
which programs are written.
And what about a program? It's a list of instructions
(or command words) that a processor (or execution unit)
understands.
Imagine the folowing situation: Your mother (or wife, by the case) sends you
to the market to buy food. She is the programmer and you will be the processor.
She writes a small program for you to execute, in this case a small (or long)
list of products to buy. When you go to the market and get them, one by one,
you are in fact executing the program instructions.
Like a "to buy" list, a program can become pretty complicated, involving
you in making comparations and takeing decisions. "If
they don't have green apples, then you should buy
oranges.". A program is also about storing and presenting the results. As you
return home, you bring the food in your bags and give them to your mother. Well,
before we all get hungry, let's continue our programming lesson.
1.2 Why another programming language ?
You probably heard about other programming languages, like C or C++, like Pascal
or Java. Are you still wondering why are you learning the GS9 language?
Well, once you have understood one programming language, you will learn any others much
easier. And it is easy to start with a simple language.
Then, different processors understand different languages. Like people from different countries, speaking
different languages, but doing the same basic stuff.
1.3 How to read this book ?
This book presents the GS9 programming language (version 3.0) and it is written
to be understood by people with no programming background. It describes the language syntax in a very similar way to other programming books.
Then it presents the GS9 libraries with special functions.
The book is written in html and tested with
Mozzila Firefox and
Internet Exporer.
Don't forget to enable JavaScript and allow active content in your browser so you can access the interactive content,
like paragraphs or examples that can be expanded or contracted. The book is also available in CHM format.
If clicking the icon will display the "JavaScript supported!" text, everything is all right.
JavaScript supported!
While reading the book, you will find various icons with different meanings.
Some of them can be clicked with the mouse to expand or contract the information attached, like the one above.
| This is an ATTENTION sign. Used for additional information. |
| This is a WARNING sign. Used to warn the reader. |
| This is a DANGER sign. Shows really dangerous things... |
| This is a PROGRAM sign. It is used to list program examples. |
| This is an IMAGE sign. It is used to show graphic images. |
1.4 The GS9 console
Along with the book, you will find a GS9 console application
that is a GS9 processor and it will be used to execute all the sample programs presented here.
If you downloaded the book into your computer, check the "console" folder and you will see it named "console.exe".
You also have a
batch file
"run.bat", that will easy your job by
launching the console with the "program.txt" parameter. The "program.txt"
will be the file where you write your programs. By default, it contains a simple
"Hello World!" program, presented in the next chapter.
So, here are the steps you must follow to test the example programs:
- Open the "program.txt" file in Notepad or any other text editor.
- Delete any previous content from the file.
- Copy the program's code presented in the book (Ctrl+C).
- Paste it in the editor (Ctrl+V).
- Save the "program.txt" file, overwriting the old version.
- Execute the run.bat file
- See the results in the console's window.
If any error occures in your program's code and the processor doesn't understand your intention, it will present an error message,
along with the line number where the error was found. This usually helps you fixing the problem, by re-editing your program.
Here are some error codes and their probable meanings:
NONE |
no error has occured. |
FAILED |
generic failure. |
FILEERROR |
the program file (or an included file) is not found. |
PARSER |
an error of syntax like a missing comma, braket, brace, semicolon, etc. |
NOLOOP |
trying use a break or continue instructions outside a loop. |
REDECLARATION |
trying to declare an existing variable or function again. |
LABELNOTFOUND |
trying to jump to an unexistent label. |
LABELEXISTS |
trying to declare a label with a name already used by another label. |
UNKNOWNVAR |
trying to use an undeclared variable or function. |
NAMETOOLONG |
trying to declare a variable or a function with a name way too long. |
BADCALLOP |
trying to call a special operator-function with bad number of parameters. |
BADTYPE |
use of an unsuported type for an operation or function (reports found and expected types). |
BADARGS |
use of unsuported argument(s) in a unary or binary operation operation (reports type(s)). |
BADARGCOUNT |
sending too many parameters to a function (reports found and expected parameters count). |
OUTBOUND |
trying to access an element outside of a string or table's bounds (reports index and bound). |
STACKUNDERFLOW |
too few values on the internal stack. |
STACKOVERFLOW |
too many values on the internal stack. |
UNKNOWNGLB |
invalid global variable access. |
UNKNOWNMBR |
invalid member variable access. |
READONLY |
trying to change a constant global variable or a function. |
DIVIDEBYZERO |
trying to divide by zero. |
STOPPED |
latent stop, it's not really an error. |
ASSERT |
a critical assertion failure. |
USER |
an user generated error (reports eventual user description). |
The meaning of these error codes, will become clear as you will learn about the things they address.
|
|