Skip navigation
Banner: GambOS Alpha 3 released
"Don't let the noise of others' opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition."

The new site is now open! Please go to Gambas Guru.

If you didn't have the opportunity to log into the new site during the preview period, you will need to choose a new password.

Hello, Guest!

Welcome to Quin's Corner

Many of the questions I've seen raised on the forum are not so much about specific Gambas issues; but more around coding in general and some of the bugs in submitters entries have been introduced by less than optimal structure in their written code.

These articles will contain information on how to plan, structure and write application code that is robust and easy to maintain in the long term.

Guest, if you have questions, just start a post on the Ask Quin forum and I'll be more than happy to answer general questions on how to structure your code and will write replies in the newsletter for some of the common questions.

Special note to "Newbies". We were ALL Newbies once, and my philosophy is that:"there is no such thing as a dumb question", so don't feel that you are alone in your quest to learn how to do things. Ask ! It's the best way to learn.

Rim Dweller - Settings things up - Folders.


Quincunxian in the usergroup ‘WIKI Editor’
Quincunxian in the usergroup ‘Community Saint’

One of the problems I was faced with in Rim Dweller, was that I needed to create quite a few folders referenced in each of the game applications for various purposes.
These can contain, binary files, micellaneous text files , image files of a few different sizes, a 'scratch' file location  and a home for the database.
I did not want to 'hard code' the paths every time I wanted to access a file so if I changed something while in development, I would not have to
go back and change each reference to a specific file.

My solution was to create a Structure of file paths and reference this throughout each of the applications used in the game.
The structure is declared in the module 'Mod_RDGlobal' which is copied to each of the Rim Dweller application projects source code areas if a change is made.

Code (Gambas)

Public Struct RDPathNames
   Root As String
   Game As String
   Server As String
   Help As String
   Scratch As String
   MiscFiles As String
   Player As String
   Mods As String
   MusicTracks As String
   SoundEffects As String
   Database As String
   SQLBuild As String
   SQLData As String
   Images As String
   Icon16X16 As String
   Icon32X32 As String
   Icon64X64 As String
   GameImages As String
   WorldFlags As String
   TarFiles As String
   Svg As String
   Tiles As String
   TileSets As String
   Logs As String
End Struct

Public RDPath As New RDPathNames

Then I set the path names in a sub called Mod_RDGlobal.Initialise and build the folder structure.
This becomes very easy and If I want to make a new folder, I just add that to the structure and I can then reference that anywhere in the application.
For example: To reference a 32 X 32 Icon, I would use Mod_RDGlobal.Icon32X32 &/ "MyIconName.png"
This has made it very easy to change things as I build the structure.

Code (Gambas)

Public Sub Initialise()
 'Assign Folder Names to Folder Structure
   RDPath.Root = User.Home &/ "RimDweller"
   RDPath.Database = RDPath.Root &/ "Database"
   RDPath.SQLBuild = RDPath.Database &/ "SQLBuild"
   RDPath.SQLData = RDPath.Database &/ "SQLData"
   RDPath.Server = RDPath.Root &/ "Server"
   RDPath.Game = RDPath.Root &/ "Game"
   RDPath.Player = RDPath.Root &/ "Player"
   RDPath.Mods = RDPath.Root &/ "Mods"
   RDPath.Help = RDPath.Root &/ "Help"
   RDPath.Scratch = RDPath.Root &/ "Scratch"
   RDPath.Logs = RDPath.Root &/ "Logs"
   RDPath.Images = RDPath.Root &/ "Images"
   RDPath.Icon16X16 = RDPath.Root &/ "Icon16X16"
   RDPath.Icon32X32 = RDPath.Root &/ "Icon32X32"
   RDPath.Icon64X64 = RDPath.Root &/ "Icon64X64"
   RDPath.GameImages = RDPath.Root &/ "GameImages"
   RDPath.WorldFlags = RDPath.Icon16X16 &/ "WorldFlags"
   RDPath.Tiles = RDPath.Root &/ "Tiles"
   RDPath.TileSets = RDPath.Root &/ "TileSets"
   RDPath.MiscFiles = RDPath.Root &/ "MiscFiles"
   RDPath.MusicTracks = RDPath.Root &/ "MusicTracks"
   RDPath.SoundEffects = RDPath.Root &/ "SoundEffects"
   RDPath.TarFiles = RDPath.Root &/ "TarFiles"


With a simple Folder creation routine.

Code (Gambas)

Private Sub CreateFolders(InPath As String)

   If Not Exist(InPath) Then
      Mkdir InPath


I am also considering 'Pre-Loading' some of the standard Icons that are used on the various Administration foms such as "Add, Change, Delete, OK, & Cancel
so that if I want to change these for different Images at any time , I just need to do this once in the Module and the change will be global.
Note# I tend not to use the stock Icons in Gambas as you can never tell what the final display will look like on various Linux distros.

Any questions or suggestions - Please feel free to add a comment.

Read more

Rim Dweller


Quincunxian in the usergroup ‘WIKI Editor’
Quincunxian in the usergroup ‘Community Saint’

Rim Dweller is a Rogue Like Space Trading game written in Gambas.
It's main focus is on exploration and trade rather than combat although there is a simple combat system.
To acomplish this, I have designed the application to procedurally create the universe based on some known physical laws.
Graphics is 2D and used 32x32 'sprites' for most graphical displays.

This Blog will record my learnings, failures, frustrations and progress as the Game development progresses.
I started designing this game around 12 years ago and have many notepads of hand written notes on concepts and ideas
and how to intigrate them all in a single game.
I've build Rimdweller to overcome the frustration I've experienced over the years in with different aspects of playing 'Space Trading' genra and their limitations and 'rules'
ie: You steal a teaspoon on some backwater planet on the distant edge of the spiral rim and immediatly every military and police official knows and will frantically hunt you down.
ie: You are in combat with an enemy ship and it's repair state is 5% but it can still fight like it's 100%  while if the tables are turned, you can't shoot, fly or do anything about it but be 'target practice'
That's never made sense to me and it's one of things that I've challanged myself to overcome !

Rim dweller will consist of 5 applications.

The installation program will create all the neccessary structures for the game such as folders and base settings.
Use FTP to automatically download new/updated files from the Rim Dweller web site.
Update the local SQLite database with any changes.
Dowload the scource code for the main game including updates and recomplie automatically. ( this is a challange )
Provide a list of Mods that you can select to intigrate into your game or remove as required.

This is the 'master' administration console that I am currently creating to build the Rim Dweller universe.
Currently sitting at 3 Modules, 67 Classes, 29 forms and around 15,000 lines of code. (I expect this to tripple in size over time)

This is a cut down version of the master administration to allow modders to create Mods for the game.
These mods can be as simple as adding a new Trade Item or as complex as adding a new Alien race to interact with.
You can create Items, Companies, Alien races, Ships, Ship AI units, Missions, Locations, Planets, Moons, Spacestations, Stars, Clusters….
Modders create 'Projects' and are assigned an 'Author'  that can be a single person or a team.
The Project data is intigrated into the Main Game if the player selects a specific Mod in the Install Process.
Mods can be removed at the start of a game including the current game.

This is the main engine for the game and 'hopefully' will allow multiplayer intigration. ( a lot of thought needed for this one !)
It can procedurally generate all the objects mention in the RDModder area and controls game behavior including ecconomics and
all the other entities that you can interact with.

This is the main game and the interface that the Player uses to Play a 'Universe' which is created on selecting "New Game"
Players can have multiple games (Universes) that they can play and can save current state of progress.
The player characture has Traits - Strength, Intelligence, Metabolism, Dexterity, Personality and Luck.
Each of these traits have a outcome on differrent aspects of the game.

Players can also have 'Perks' which are described as inate abilities that affect the player statistics.
For example:
The 'Bookworm' Perk increases your Intelligence and give a better outcome of any training that you do.
The 'Computer Geek' Perk allows you to better manage your computer systems on your Ship or interact with Location AI systems.

Items that the player used in the game can be of 2 Types.
Trade Items or Interactive Items.
Trade Items are simply that, you can trade with other entities in the game for 'credits' or other Items.
Interactive items can be used in the same way as trade items but you can also interact with them.
For example:
You may purchase a Shield Generator. You can have this fitted to your ship provided it is of the correct Model.
You can upgrade the generator with Firmware cards depending on how many 'Slots' it has available ( 0-3)
These cards will ajust the base stats for the Generator in various ways such as increasing the shield strength,
but… may increase the Power requirements and running temperature that will require more cooling.
You can fit Interaqctive items to you ship that are not the required model by using 'Adapter Plates' ( even Alien Tech)
The downside is that Adapter plates decrease functionality by a percent and are not always stable, depending on
the difference in model that you are trying to adapt. The chance of failure get's higher as the device ages.

Ships that the Player uses can be of many types and configurations.
Unlike 3G games, what the ship looks like externally is not as important but how it is configured internally is for Rim Dweller.
At the start of the game you have to do many things manually such as repairs and managing cargo.
As the game progresses, you can buy Droids that can take over many of these mundane tasks for you.
"A good Tech Droid is worth it's weight in Neodymium"

This is a taste of what Rim Dweller is designed to become ( if I live long enough) and I have no idea of a estimated finish date yet.
I'll make posts to this Blog as I make progress and try out new things and refine my knowledge of Gambas ( which is part of the reason why I'm doing this )

If anyone has any ideas for concepts or questions about Rim Dweller or Space Trading Game in general then please leave a comment.
(I've been playing Space Trading Games since 1978 'Galactic Merchant' was the first on my 16K RAM TRS-80, Cassette loaded system )


Read more

Modules 101


Quincunxian in the usergroup ‘WIKI Editor’
Quincunxian in the usergroup ‘Community Saint’

What are Modules ?

A Module is a object in Gambas that contains variables and subroutines that are available to your entire project.

Like a normal class, you must create the variable or subroutine as PUBLIC for it to be accessable to your project code.
PRIVATE variables and subroutines are only accessable from within the Module that they are created in.
However, unlike other programming languages such as Visual Basic .Net and C++, in Gambas you must also reference the Module name to access the variables.

If you have a global variable called ApplicationName that you want to use in your project you would declare it as PUBLIC in your Module.

Create a Module and name it "mGlobal"
add the line :


PUBLIC ApplicationName as String = "My Application Name"

Then, in your other forms or classes, you referency this by writing mGlobal.ApplicationName
For example: on the Form_Open event for each form, you can add the following line:


Me.Text = mGlobal.ApplicationName & " Ver: " & Application.Version

This will provide a consistant name and application version text for all of your forms.
Now if you want to change the name of your application, you only have to do it once in your module !

You can also have reference to Classes in your module.

Create a Class called "cMyDetails" and declare the follwing variables.


PUBLIC MyName as string = "Fred Bloggs"
PUBLIC Age as Integer = 21
PUBLIC EMail as String = ""

Now in your Module, add the following:


PUBLIC MyDetails as New cMyDetails

Now anywhere in your project you can reference your EMail address using the variable



You can have more than one module in your project and even have the same variable name in each.
For example:
Create a module called "mSQLITE" with the following code:


PUBLIC $Con as Connection

PUBLIC SUB InitialiseDataBase()
   $Con = New Connection
   $Con.Type = "sqlite"
   $Con.Name = "mydatabaseName"

Create a Module called "mMySQL" with the following code:


PUBLIC $Con as Connection

PUBLIC SUB InitialiseDataBase()
   $Con = New Connection
   $Con.Type = "mysql"
   $Con.Name = "mydatabaseName"
   $Con.Password ="SomePassword"
   $Con.User = "SomeUserName"

Now you can initialise the database connection by calling the appropriate module and function.

mSQLITE.InitialiseDataBase OR mMySQL.InitialiseDataBase
Both have the $Con variable declared but as they are declared in different modules, they is no naming conflict.

So you can reference the database name for each connection as:

What sort of things do I put in Modules ?

Any variable or constant that you want to be accessable throughout your entire project.

Any Subroutine or Function that is generic for your entire project.

For example:
You want to give all your sub froms the same look and feel when they open.
Enter the following code into your "mGlobal" module


Public Sub OpenSubForm(InText As String, ByRef InForm As Form)

   InForm.Text = InText
   InForm.SkipTaskbar = True


Now in your main form when you open a sub form, instead of using:




It will centre the sub from on the screen, add some descriptive text to the title bar and NOT display it in the Taskbar.
Note # The sub form is passed to the subroutine ByRef so any changes that we make to the form affect the actual form passed.

Happy coding.

Read more

Older blog posts