Archive for the ‘Gambas’ Category

Ubuntu Forum beginners challenge #9

February 21, 2010

I wrote the following short program as a response to a ‘beginners programming challenge’ on the Ubuntu forum. I just got so tired of all the terminal-based solutions and chided the contestants that even phones had GUIs these days! It was kind of difficult separating original entries from rehash/error-correction but the tallies (by the time enthusiasm seems to have got lost) was:

PHP 11
C 4
Java 4
Python 4
Bash 2
C++ 1
Gambas 1
Haskell 1
Lisp 1
OO Spreadsheet 1
Perl 1
Scheme 1
Userland/awk 1

I didn’t see much evidence of ‘beginners’ in the entrants.

Anyway the brief was:
Your program should be able to open a text file and read its contents. The file will consist only of LOWERCASE letters and numbers 0-9. The file will be formatted such that there is only one alphanumeric character per line.
Your program must read each line and store the data in a data structure of your choice. Parse through your structure and print out the following information:

1. The sum of all the individual digits.
2. How many times each character appeared in the file.

I have put the code in a page on the right. It just needs a few standard objects on the form: a filechooser (default name filechooser1), a listbox (listbox1), a button named btnExit and a button named btnRun. If any real ‘beginner’ needs help to get this going, just shout.

It is easy enough to cut and paste from the blog although I have also put the source code as a tar.gz at Prog Challenge Source.

Gambas also does a good job at compiling run-time versions of applications and I have put a Debian package installer at Prog Challenge Installer.


Gambas FTPClient

February 7, 2010

FTP (File transfer protocol) is used to send and receive files over the internet. I have issue with a lot of the supplied Gambas examples in that they often over-complicate the process they are trying to demonstrate. New users, searching for the answer to a particular problem, need the bare-bones answer: something on which they themselves can then build. Searching on ‘Gambas’ and ‘FTP’ currently leads to samples of amazing complexity with timers and event-logs all over the place to the point where you just can’t get the essence of the sample itself.

Well here is the bare-bones of FTP in Gambas:

‘ Gambas class file
PRIVATE myFTPClient AS NEW FtpClient

PUBLIC SUB Button1_Click()

myFTPClient.User = “fred”
myFTPClient.Password = “dog”


Now, how simple is that? The .URL includes the file name on the ftp server and the .Put gives the local filename that you want to send. You won’t be surprised to hear that there is a .get method to do it the other way round.

Ideally you would do a bit more e.g. monitor theFTPClient.status to check completion.

Make sure you click on networking components when you create the project (or click on and in project,properties,components)

Gridview and the Data Handling Event

December 10, 2009

I have put a short tutorial about this very useful feature in a page on the right.

Tutorial Update

October 7, 2009

I have updated the tutorial and renamed it Gambas 2.8 on Ubuntu 9.04 (in pages on the right). I have just removed the reference to the external repository (which no longer worked).

It would be nice if Ubuntu could offer a more up-to-date version of Gambas. Other distros seem to manage it. Actually, even Gambas 2.8 is quite usable.

As mentioned the current stable version is 2.19.0 and compiles from source quite reliably on Ubuntu 9.10. The development version of Gambas 3 is (I guess) nearly ready.

Opus Minimus

June 28, 2009

Well, at long last my Gambas project is up an running. In my small retail business I have used an in-house Point-of-sale system based on VB6 and Access97 for nearly 10 years. I lost interest in developing the system further because I found it increasingly difficult to re-install on modern equipment. One of my tills and the ‘file server’ were still running Windows 95, LOL.

Well, I have now cloned the system onto Gambas 2, mySQL and Ubuntu 9.04. I won’t say it’s completely bug free yet but it is up and running. It has helped that the staff has been positive about the changes. I have two tills, a separate goods receiving machine and an admin machine using one of the tills as a server. There is a cunning plan, carried over from the old system, whereby the machines can run stand-alone if the network crashes (I only used it once in the last 10 years).

The goods received program and point-of-sale program are separate and both are mouse-free. This adds enormously to the code but is something that I think Gambas excels at. The point-of-sale is just less than 2000 lines of code and the goods received about 1300.

I cannot fault Gambas and am stunned by the speed of SQL searches (even on un-indexed fields) in mySQL. I just lurv Ubuntu 9.04 probably because Nautilus file manager works just the way I do. I now look forward to developing the system further although I accept the adage that one shouldn’t develop software and run a business at the same time! I just enjoy programming too much!

POS runs 800x600 on 15in LCD

POS runs 800x600 on 15in LCD

Goods Received runs 800x600 on 17in CRT

Goods Received runs 800x600 on 17in CRT

Update on Gambas tutorial

May 9, 2009

Well things have changed since I first wrote the tutorial. The azores.linux site that I used to get an updated installation for Ubuntu no longer works. On the plus side, Ubuntu 9.04 now comes with Gambas 2.8 as standard although you have to use Synaptic to enable more than the bare minimum. The standard installation also does not put a Gambas option into the menu so you have to use the launcher as described in the tutorial

Fedora 11 (and I think the current Fedora 10) has easy access to Gambas 2.12. I also see the Gambas 2.12 is available on FreeBSD.

You can find the tutorial ‘Gambas 2.8 on Ubuntu 8.04’ under ‘pages’ in the right hand menu.

Musings about Gambas and Linux from a non-expert!

June 5, 2008

I hope to develop this site with random snippets aimed at the less technical Linux user.

Linux does tend to rely on the extended computer knowledge of its users which (I know) can be quite dispiriting for the rest of us.

The only useful entry at the moment is the ‘Gambas 2.8 on Ubuntu 8.04’ tutorial in the menu to the right.