What is GAMBAS ?

Why GAMBAS ?

The GAMBAS language

The GAMBAS components

The future of GAMBAS

Welcome to
GAMBAS!

What is GAMBAS ?

GAMBAS is an interpreted language with BASIC syntax and object-oriented features.

It is made up of:

A compiler.

An interpreter.

An archiver.

Many components.

A development environment.

A useless moving mascot...

What is GAMBAS ?

A GAMBAS project is a set of:

classes

modules

forms

and data files

all being stored into one unique directory.

What is GAMBAS ?

The development environment allows you to develop GAMBAS project easily.

Syntax highlighting.

Automatic completion.

Graphical GUI design.

Translation.

Debugger.

What is GAMBAS ?

The interpreter runs the projects compiled by the compiler.

The archiver makes one script file from an entire project.

What is GAMBAS ?

The form files are transformed into GAMBAS source code.

The source code is compiled into an internal binary
bytecode.

GNU translation tools are used for extracting the strings to be translated from the source code.

Compiling a project only requires the compilation of the modified classes.

Every external reference of a class is solved dynamically at the execution time.

What is GAMBAS ?
The compiler

The interpreter includes all native instructions and functions, and all native classes (the gb component).

The class loader loads the classes compiled by the compiler when needed.

The bytecode is linked and optimized at first run.

The debugger allows the user to trace the program step by step, to set breakpoints...

The component loader loads the components specified in the project at startup.

The component interface allows the component code to communicate with the interpreter.

What is GAMBAS ?
The interpreter

Why GAMBAS ?

Writing your own language is funny and exciting.

I wanted to create something visual, easy, basic. And BASIC too.

I was traumatized by the phenomenal quantity of bugs and inconsistencies in similar environments that I had to use at work.

I didn't want to learn Perl, Python... And I am not in love with Java.

I think GAMBAS can become a complete development platform like Java or .NET / Mono.

Why GAMBAS ?
Why I started this project

GAMBAS is easy to learn: for beginners, and others.

The development environment is easy too. Developing a GUI is fast.

GAMBAS is still an object-oriented language with inheritance.

GAMBAS components are not just bindings to existing libraries. Their interfaces try to be as simple and coherent as possible.

GAMBAS components try to abstract the libraries they are based on. The QT and GTK+ components have the same interface, as do the MySQL, PostgreSQL and SQLite databases components.

Why GAMBAS ?
Why using it

The GAMBAS Language

Access to variables, methods and constants.
PRIVATE / PUBLIC / STATIC / DIM

Declaring methods.
PROCEDURE / SUB / FUNCTION / END

Declaring constants.
CONST

Declaring properties.
PROPERTY

Declaring events.
EVENT

Inheritance.
INHERITS

The GAMBAS Language
Describing a class (or a module)

The GAMBAS Language
Simplified datatypes

DIM <variable name> AS ...

BYTE / SHORT / INTEGER

BOOLEAN

FLOAT

STRING

DATE

VARIANT

OBJECT

<Class name>

SINGLE / LONG

The GAMBAS Language
Constants

TRUE / FALSE

0 / 123 / -32769

&H1F5 / &FFFF / &H10BF332E

&H8000& / &HFFFF&

&X1010010101 / %101001011

1.0 / -5.345219E+45

"Hello world!\n"

"This" "string" "is" "cut"

("This software is cool")

NULL

String that must
be translated

The GAMBAS Language
Conditional and flow management

IF / THEN / ELSE / ENDIF

BREAK / CONTINUE / RETURN

SELECT / CASE / DEFAULT / END SELECT

DO / LOOP

WHILE / WEND

REPEAT / UNTIL

FOR / TO / STEP / NEXT

FOR EACH / NEXT

GOTO

WITH / END WITH

Enumeration of
enumarable objects

The GAMBAS Language
Error management

Error are managed by catching them inside a procedure or a function:

SUB MyFunction()

TRY <to do that>

...

CATCH

PRINT "Error "; Error.Text; " in "; Error.Where

...

FINALLY

...

END

The GAMBAS Language
Input-outputs

OPEN <file name> FOR [ READ ] [ WRITE ] [ CREATE | APPEND ] [ DIRECT ] [ WATCH ] [ BIG | LITTLE ] AS # <variable>

CLOSE

FLUSH

INPUT / LINE INPUT / READ

PRINT / WRITE

SEEK / Seek

Eof / Lof

Streams and the File class

The GAMBAS Language
Object management

Static and dynamic variables.

Inheritance.

Virtual dispatching.

Constructor and destructor.

No garbage collector. Objects are freed when they are not referenced anymore.

Special methods for using the object like a method, for accessing it with the [] operator, and for enumerating it with the FOR EACH instruction.

Properties.

Events.

The GAMBAS Language
Object management

Object instanciation

<variable> = NEW <class name> [ ( <constructor parameters>... ) ]

ME / SUPER

Event observer

<variable> = NEW <class name> [ ( <constructor parameters>... ) ] AS <event name>

LAST

RAISE / STOP EVENT

The Object and Class classes

The GAMBAS Language
The GAMBAS event model

All objects can have an event observer, or parent. This is by default the object where the child object is created.

All events raised by an object are handled by a public method of its parent: the name of this handler is the event name of the object specified when it was created, an underscore, and the name of the event.

You can change the object parent during its life with the Object.Attach and Object.Detach methods.

hServer = NEW ServerSocket AS "MyServer"

...

PUBLIC SUB MyServer_Connect()

The GAMBAS Language
String management

Left$ / Mid$ / Right$

Len

InStr / RInStr

LIKE

LTrim$ / RTrim$ / Trim$

LCase$ / UCase$

Replace$ / Subst$

Space$ / String$

Split

GAMBAS and graphical components use UTF-8 strings: The String class

Very important
for translation!

The GAMBAS Language
Mathematical and logical functions

+	-	*	/	\	MOD

AND / OR / NOT / XOR

DEC / INC

Abs / Sgn

Acs / Acsh / Asn / Asnh / Atn / Atnh / Cos / Cosh / Sin / Sinh / Tan / Tanh

Deg / Rad / Pi

Exp / Log / Log10 / Sqr / ^

Fix / Frac / Int / Round

Max / Min

Randomize / Rnd

BChg / BClr / BSet / BTst / Rol / Ror / Shl / Shr

The GAMBAS Language
File management

&/

COPY / LINK

KILL

MKDIR / RMDIR

RENAME

Access

Dir

Exist

IsDir

Stat

Temp$

PRINT System.Home &/ "Desktop"

/home/benoit/Desktop

There is no
current directory
in GAMBAS.

If a file path is relative
it refers to a
file located in
the project.

The GAMBAS Language
Date and time management

Date

Day / Month / Year

Hour / Minute / Second

Now

Time

Timer

WeekDay

GAMBAS dates are stored as a number of days and a number of micro-seconds, in GMT.

They can be converted to Float : the integer part is the number of days, and the fractional part the resting time.

The GAMBAS Language
Conversion and datatype

Asc / Chr$

Bin$ / Hex$

CBool / CByte / CDate / CFloat / CInt / CShort / CStr

IsBoolean / IsByte / IsDate / IsFloat / IsInteger / IsNull / IsNumber / IsObject / IsShort / IsString

TypeOf

Conv$

Format$

Str$ / Val

Use localization
settings

The GAMBAS Language
Process management

Running an external process

EXEC <command> [ WAIT ] [ FOR ( READ | WRITE | READ WRITE ) [ AS <variable> ]

Running an external shell command

SHELL <command> [ WAIT ] [ FOR ( READ | WRITE | READ WRITE ) [ AS <variable> ]

The Process class

The Read and Error event

The GAMBAS Language
Miscellaneous instructions and functions

In-place arrays

Array / [ ... ]

Evaluating dynamic expressions

Eval

Creating objects dynamically

New

Choose / IIf

SWAP

The GAMBAS Language
Native classes

Application

Byte[] / Date[] / Float[] / Integer[] / Object[] / Short[] / String[] / Variant[]

Class / Classes

Collection

Component /	Components

Error

File

Process

Settings

String

System

Object

gb

The GAMBAS Components

The GAMBAS Components
gb.compress
The compression / decompression library

This component allows for compression and uncompression of files and to read and write compressed files using standard stream methods.

It also allows for compression and uncompression of strings in memory.

It currently uses the algorithms provided by zlib (used by gzip) and libbzip2 (used by bzip2) libraries.

The GAMBAS Components
gb.db
Database access component

This component allows you to access the following database management systems:

PostgreSQL

MySQL

SQLite

You can write code that is completely independent from the database backend.

Example: the GAMBAS database manager

The GAMBAS Components
gb.eval
GAMBAS expression evaluator

This component is used for evaluating GAMBAS expressions at runtime.

It is automatically loaded if you use the Eval() function.

It can evaluate precompiled expressions and can take the value of its unknown symbols from a Collection.

PRINT Eval(Subst("Sin(&1) + Cos(&2)", 1, 2))

0.425324148261

The GAMBAS Components
gb.net / gb.net.curl
The networking components

The gb.net component allows you to:

Implement network clients and servers (TCP or UDP).

Do DNS requests, synchronously or asynchronously.

Manage serial port devices.

The gb.net.curl component allows you to retrieve of http, ftp and potentially other files via the network.

It is based on the libcurl library.

The GAMBAS Components
gb.qt / gb.qt.ext
The graphical QT 3.x toolkit components

These components implement all the stuff
needed to develop a GUI based on the QT toolkit.

Controls, containers, menus, ...

Managing clipboard.

Using drag & drop.

Drawing and printing.

Managing mouse & keyboard.

And so on...

The QT library interface is abstracted and simplified.

The GTK+ component will have the same interface!

The GAMBAS Components
gb.qt.editor
The GAMBAS editor with syntax highlighting

This component allows the GAMBAS IDE to have a code editor with:

Syntax highlighting

Procedure splitting

Code rewriting

The highlight process
is internally done by the gb.eval component.

The GAMBAS Components
gb.qt.kde / gb.qt.kde.html
KDE integration, scripting, and web browser

This component allows the use of some KDE features:

KDE standard dialogs.

Web browser, thanks to the KHTML widget.

Automate applications with DCOP.

How to change your KDE wallpaper with GAMBAS

DIM hApp AS Object

hApp = Application["kdesktop"]

hApp.Background.SetWallpaper(<image path>, 1)

The GAMBAS Components
gb.vb
Visual Basic™ compatibility

This component includes some functions that are missing in GAMBAS, or whose behaviour is different between GAMBAS and Visual Basic™:

DateAdd / DateDiff

Left$ / Mid$ / Right$

Round

Str / Val

The aim of this component is helping porting Visual Basic™ projects to GAMBAS.

The GAMBAS Components
gb.xml.libxml / gb.xml.libxml.xslt / gb.xml.libxml.rpc
XML tools

The gb.xml.libxml component is an interface to the libxml XML library.

The gb.xml.libxml.xslt component is an interface to the libxslt library.

The gb.xml.libxml.rpc component allows to be a XML-RPC client. It is based on libxml and libcurl.

These components are in beta version.

The GAMBAS Components
gb.gtk
The graphical GTK+ toolkit component

It will have exactly the same interface as the gb.qt component.

This way, the same program will be able to switch between the QT toolkit and the GTK+ toolkit, without changing one line of code!

This component is based on the GTK+ toolkit.

The GAMBAS Components
gb.pcre
The Perl Compatible Regular Expression component

This component provides regular expression matching compatible with Perl.

It is based on the
libpcre library.

How to match a string against a pattern

DIM r AS Regexp

r = NEW Regexp(subject, pattern)

IF r.Offset >= 0 THEN

PRINT "Match"

ELSE

PRINT "Don't match"

ENDIF

The GAMBAS Components
gb.sdl / gb.sdl.image / gb.sdl.sound
The SDL components

This component provides you the power of the SDL library so that you can write games:

2D SDL graphics management.

Mouse and keyboard.

32 sound tracks and one music
track mixed together with the
gb.sdl.sound component.

CD-ROM management.

The Future Of GAMBAS

The Future Of GAMBAS

Language enhancements...

EXEC ... TO /	EXEC ... FOR INPUT

Virtual dispatching

Currency support

Preprocessor: #IF, #ELSE, #ENDIF...

Making components directly in GAMBAS.

New components:	SDL, GTK+, PCRE...

A report designer.

Visual-Basic™ support enhancements.

Making Web applications in GAMBAS.

An object persistence system.

...

Conclusion

ﾲ

The two stronger and greater feelings of the humanity are...

Love
and...

Fighting for freedom.

2005-02-14T16:32:13