Primeros pasos en Gambas

Introducción

Usted ha elegido usar el lenguaje de programación Gambas. Buena elección, muy buena elección. Gambas es un lenguaje de programación que es muy fácil de aprender y usar. Es un lenguaje de programación claro, fiable, sencillo y Usted puede hacer muchas cosas con él.

La mejor manera de empezar con Gambas, es practicar en la consola para aprender la base de su sintaxis.

Toma en cuenta que si eres un antiguo usuario de Visual Basic o QBasic, no te perderás. ¿Por qué? porque Gambas utiliza una sintaxis muy parecida a los lenguajes VB y QBasic.

Crear un nuevo proyecto

If you don't have installed Gambas yet, please before going to this page.

comeinza por lanzar y ejecutar gambas3. First of all, a beautiful window opens by asking you what you want to do :

Click on New project. This window will open to every startup of Gambas and will allow you to run quicky what you want.

As you can see, it's relatively simple to create a new project, and you are guided step by step for his create. Here, choose Command line application and click on the Next button.

Here, select your folder where your Gambas project will be saved.

Then, give a name and a title to your project. Applied all by clicking on *OK button.

And here is the result!

Once your project is created, you are into the IDE of Gambas and another beautiful window opens which wishes to you the welcome in Gambas ! In your first step with Gambas, you should prefer to keep this tips window at startup. In this way, you will have more information about Gambas and its particularities as well. You will see the informations gave by that window are helpful :-) .

For the VB users, that tips window allows you to know what are the difference between Gambas and VB.

Your first program in Gambas

If you look at on the left of the IDE, you will see that you've got a module named MMain :

Click twice on it to open the editor. You have a base code like that :

Examples

' Gambas module file

PUBLIC SUB Main()

END

This is the main procedure of your program. i.e, it's the first procedure which is executed by the Gambas interpreter. The first of this code is a comment. You can recognize them because there've got a grey color into the editor and begins always by an apostrophe. Comments are useful to indicate informations about source code. For example, to explain what the source code do.

We're going to see how to display something on the screen. To do this, we're going to use the PRINT statement which allows to write on the standard output. The text must be set between quotes:

' Gambas module file

PUBLIC SUB Main()

  PRINT "My first program!"

END

To run the program, press the F5 key or you can run it by Debug -> Start menu, or by the toolbar yet:

A small frame opens at the bottom of the IDE, this is the console. When executing the program, we're getting:

My first program!

To try out in detail the PRINT statement, we're going to add a second PRINT statement:

' Gambas module file

PUBLIC SUB Main()

  PRINT "My first program!"
  PRINT "Made in Gambas :) !"

END

Congratulation ! You made your first program in Gambas ! :-)

Now, we can go to the following tutorial. It will talk about variables, a point which is very important in programming. - Variables