Regarding Gambas

For a few years, I’ve been working in the real world, I mean the enterprise world, sorry. In every company I’ve worked for, they offered me the opportunity to learn a lot of new things, or at least that’s what they always said in the first meeting before sending me to be just another company programmer. But in fact I’ve learned some very important things, just not about programming. I had to learn about these things on my own, about the needs of a real company in the real world.

Software schedules are usually tight. Big custumers think like that old Queen song: “I want it all, and I want it NOW”. Modifications must be done quickly, sometime multiple times, as customers change their mind often. And there’s not just one big custumer, but a hundred important customers for our company, and our program must be adapted to work in different environments.

However, not all programming tasks need a real programmer. There are few programmers, and all the employees need your services. You can’t do all, and you don’t have the time to learn all about marketing, administration, statistics, sales, and all the rest of things existing in a modern company. It would be a tremendous advantage if experts in these fields had the ability to write simple programs to meet their own needs.

Programming in C or C++ is effective, and the basis for much of the world’s most important software. Think about Linux; more than a million lines of code written in C, and it works like a charm thanks to C’s inherent strengths. However, coding in C or even in C++ is slow and cumbersome if you want to program an interface for a database in a day. But there are many cases where someone in a company, or just a computer user in their house would want to do some simple programming to automate a task.

Programming languages like Perl or Python are nice too, especially for web tasks, but they’re designed for programmers, and they have important shortcomings for the beginner, for example, lacking a really easy and comfortable IDE.

On the other side, a lot of old computer users, whether they are currently working as programmers or not, began using computers with well known names like MSX, Spectrum, Commodore, or Amstrad. All of them had their own BASIC interpreter, and almost everyone who used computers back then remembers something about BASIC. Due to the success of a small software company back in the 80s, I can’t remember the name, sorry, BASIC was also extended to manage databases, spreadsheets, and there’s even a good IDE for a BASIC dialect thanks to that company, and a lot of programmers have learned that this BASIC dialect is poor, and has bugs, but they can easily write and debug programs using it, so they have become productive for their companies.

New things like C# are also good for big projects, but for a beginner it’s just confusing when they read things like “System Runtime Interop Services”, and they realize that they have to learn about name spaces, inheritance, interfaces and provider objects before writing anything useful.

So it seems there’s a good place for an easy and powerful language, so both beginners and programmers that need to concentrate in the problems instead of the syntax, can work without problems. That’s where Gambas can help the free software community. Gambas offers an easy IDE and a BASIC interpreter that allow the user to create both graphical and console programs, database applications, and communications programs. Even CGI’s can be written with few effort. And it is ready; the 1.0 version will be out soon.

Getting started
Let’s program using Gambas. You can download and compile the sources from the download section of Gambas , or if you’re using Mandrake, you can download the latest version from, or install it from the “contrib” section of Mandrake distribution. Debian Sid/Sarge/Linex users can do it just typing “deb sarge linex”. There are packages for other distributions like Slackware, too. Just look the download page, in the “Binary packages” section.

Once you’ve installed it, run Gambas. The first screen shows a wizard that allows you to open some example programs, open recent projects and to create a new project.

Let’s create a new project, so press the “New Project” option. Then press “next”.

Select “Create a graphical project”, then press “Next”.

In the “project” name type “MyProgram”, for example, and in the application title place any description, for example “This is my first program” or leave it blank, if you want.

In the next screen select a folder into your home directory where you want to save the project. The IDE will create a folder, with the same name as your project, into selected folder. Finally, a little resume of the options you’ve selected, and after pressing “Finish”, you will have access to the RAD environment to start developing your project.

Go to “Forms” the press the right button and select “New Form”. A dialog appears asking for the project properties.

Call it “FrmMain” the press OK.

Now in the “ToolBox” window, click on the button widget, go to your created form, and place it there resizing it as you want.

Now modify the button text, write “Hello” in the “Text” property of that button.

Let’s code a little. Double-click your button. The code editor will appear. Just write the code for the button:

Message.Info ("Hello, World!")

Now, execute your program. To do that, press “F5” or the “run” button. To test the program click your button. A dialog appears with the welcome message. Easy, isn’t it?

Gambas can do more!
This was just a very little example. However, Gambas allows you to write complex programs. The RAD environment is written in Gambas itself. You can write multi language programs. To help you doing that, the RAD offers a wizard to translate your programs to a lot of languages. All translations are compiled with the main executable, and according with the user language, the program will automatically show the texts in a language or another. All form texts are automatically added to the translation wizard, and you can select if any of the texts written in the code must be translated or not. A usual string (between the ” symbols), is not translated, but if you round it with the “(” and “)” symbols, it will be available for translating:

Text1.Text="This string will be not translated"<p>
Text2.Text=("This string will be translated")

Gambas offers database access. Cvurrently you can manage MySQL, PostgreSQL and Sqlite. You can write code to read and alter table contents, and even to create and delete databases and tables. Gambas RAD also provides a database manager, that allows you to graphically connect with a database server, create and destroy databases, tables and records in a table. It also offers interesting features, like translating table structure to Gambas code, so you can create the table in any new installation without having to write the “CREATE TABLE” statements by hand, or database users management.

A complete documentation system can help you when you are in trouble. That documentation is being updated all the time, as it is placed in a wiki at Binara. There’s a Spanish translation in progress at Linex.

There are wizards to distribute your program as source code (tar.gz format) and to create binary packages for the main GNU/Linux distributions. You can create a rpm or deb package without knowing the build tools for these package systems.

You can write network applications using Gambas; there’s a low level network component that allows to write TCP, Unix and UDP socket clients and servers, and to work with serial port devices. A beta component, based on the curl library, allows to directly perform querys to HTTP servers and work as an FTP client.

XML is work in progress, soon you’ll be able to read and write XML files, perform XML-RPC calls and make conversions to XHTML using XSLT.

The components model
Gambas is designed to be extensible. There’s a base language, and all the rest of the features are provided by components. Currently, components are written in C or C++, and in the future you’ll be able to write your own components in Gambas! Even the graphical toolkit is just a component. By default, Gambas can just be use for console programs, but adding the qt component, the program becomes a graphical application. This qt component is as agnostic as possible, so in the future there will be a GTK+ component, that will work absolutely the same as the qt component, allowing you to decide what low-level toolkit to use.

The future…
Gambas is just 1.0. In the next year there will be a lot of advances: finishing the network and XML component, writing components in Gambas, serialization, persistence, sound and graphics with SDL, a GTK+ toolkit, a report designer, data widgets (grids, combo-boxes…)…

So, if you plan to write the applications for your home financials, or have to write programs for big customers, think of Gambas, it can make you productive, fast, smart, and all the kind of things that big companies marketing campaigns say, with the freedom of GNU/Linux or FreeBSD, and the support of a big team of volunteers!

About the author:
Daniel Campos Fernández Programmer and System Administrator.
Working for Gambas since 2003, writing the network, XML/XSLT, and compression components.

If you would like to see your thoughts or experiences with technology published, please consider writing an article for OSNews.


  1. 2004-11-11 9:00 pm
  2. 2004-11-11 9:12 pm
  3. 2004-11-11 9:19 pm
  4. 2004-11-11 9:22 pm
  5. 2004-11-11 9:24 pm
  6. 2004-11-11 9:26 pm
  7. 2004-11-11 9:40 pm
  8. 2004-11-11 9:42 pm
  9. 2004-11-11 9:51 pm
  10. 2004-11-11 9:56 pm
  11. 2004-11-11 9:59 pm
  12. 2004-11-11 10:02 pm
  13. 2004-11-11 10:04 pm
  14. 2004-11-11 11:24 pm
  15. 2004-11-11 11:46 pm
  16. 2004-11-12 1:26 am
  17. 2004-11-12 1:29 am
  18. 2004-11-12 2:12 am
  19. 2004-11-12 2:51 am
  20. 2004-11-12 2:56 am
  21. 2004-11-12 5:16 am
  22. 2004-11-12 8:22 am
  23. 2004-11-12 8:54 am
  24. 2004-11-12 9:09 am
  25. 2004-11-12 9:16 am
  26. 2004-11-12 9:30 am
  27. 2004-11-12 10:32 am
  28. 2004-11-12 11:50 am
  29. 2004-11-12 11:57 am
  30. 2004-11-12 12:26 pm
  31. 2004-11-12 12:35 pm
  32. 2004-11-12 12:43 pm
  33. 2004-11-12 1:04 pm
  34. 2004-11-12 2:02 pm
  35. 2004-11-12 3:20 pm
  36. 2004-11-12 3:45 pm
  37. 2004-11-12 5:23 pm
  38. 2004-11-12 5:56 pm
  39. 2004-11-12 6:48 pm
  40. 2004-11-12 8:16 pm
  41. 2004-11-12 8:54 pm
  42. 2004-11-12 10:12 pm
  43. 2004-11-13 9:09 am
  44. 2004-11-13 9:47 am
  45. 2004-11-14 11:46 am
  46. 2004-11-15 1:43 am
  47. 2004-11-15 2:29 am
  48. 2004-11-19 4:28 pm