Basic Programming Programmers Have Been Looking for a Visual Basic Clone for Linux for Quite a While Now
Total Page:16
File Type:pdf, Size:1020Kb
LINUX USER Gambas Gambas Basic Programming Programmers have been looking for a Visual Basic clone for Linux for quite a while now. Gambas is well on the way to closing this gap. BY FRANK WIEDUWILT or many Linux converts losing a Now change to the directory you just simple programming language like created, gambas-0.38, (cd gambas-0.38)), FBasic, which is extremely useful for and type the following commands in the straightforward programming tasks, was following order: ./configure, make, and a hard blow. Gambas [1], which means ensuring that you are root, make install. “Gambas Almost Means BASic”, offers a This completes the installation of the developer environment that is similar to program, which you can now launch by Visual Basic. Gambas’ author, Benoît typing gambas & in a shell. Minisini, has created a program that allows you to create graphic interfaces Initial Launch with just a few mouse clicks, and it After launching the program, you are comes complete with a convenient editor prompted to choose between creating a for writing source code. new project or openening an existing one. If you select New Project, Gambas will Installation prompt you to enter the directory where You will find Gambas on this issue’s you will be storing the project files before subscription CD. To compile Gambas you opening a number of windows where you Figure 2: Form Designer and Toolbox will need both the sources, and a QT can edit your project files (see Figure 1). version > 3.0.2. Users of SuSE Linux The left panel then shows an overview A Question of Forms version 8.0 should use Gambas 0.37, of the current project in a tree structure. A GUI tool is available for creating which is also included on the subscription The top panel on the right contains a forms. You can use the Form Designer CD, as Gambas 0.38 will not compile on selection of GUI elements that you can just like a drawing tool to position your distribution. add to the program interface – the individual elements on the background Type the following command in your properties of the selected element are of the programming environment (see favourite shell to expand the gambas- displayed on the right. To start Figure 2). 0.38.tar.gz archive: programming, simply draw one or A full selection of components multiple windows – Gambas refers to typically required for GUI programming, tar -zxvf gambas-0.38.tar.gz them as forms. such as a buttons, text boxes, combo Figure 1: Gambas Figure 3:The Component Explorer 84 Dec 02 / Jan 03 www.linux-magazine.com Gambas LINUX USER button in the editor window. The drop- down menu that appears contains a full selection of commands for source code editing. The editor also allows you to define breakpoints and select variables for debugger traces. More support for keyboard shortcuts would be useful – to avoid having to continually switch between keyboard and mouse while coding. However, the fact that the editor automatically capitalizes Basic keywords, highlights commands and remarks is quite useful. You can customize the editor to suit Figure 4:The Menu Editor your requirements by choosing colors for Figure 5:The Source Code Editor the text background, and for syntax boxes, tree and table view, and picture highlighting. Unfortunately, Gambas boxes, is available. will not allow you to integrate your Now select the required element in the favorite editor, such as Kate or Emacs, toolbox, and drag it to the required size for example. in the form window. You can use the However, the forms and classes are Properties window to edit the element’s stored in text format, which would allow properties. A grid is available to ensure you to use another editor for any source exact positioning of the elements. code authoring before you compile it Use the Properties window to specify with Gambas. the name and appearance of the ele- ment. Double clicking an element will Bug Hunting open the source code editor where you Debugging source code can often turn can type directives to define the various out to be quite a challenge. Gambas events that the element will react to. provides the developer with a debugger Each GUI element has a number of that allows you to trace variables at run properties, such as color, size, and time and define breakpoints (Figure 6). Figure 6:The Debugger position, for example, and also a number of methods. Linking Gambas Language Encyclopaedia, which To determine the options available for Gambas provides a compiler, that will also contains a few sample programs. a specific element, simply launch the translate your Basic source code into an The file is available both as a PDF and in Component Explorer (see Figure 3). executable. You press the [F7] key to StarOffice 5.2 format. Select an object in the left panel to launch the compilation process. If display its properties and methods in the everything works out ok, the executable, Conclusion right panel. A convenient Menu Editor is which will be named after your project, Gambas is an interesting project. Even at available to help you create menus – just appears in the project directory. You will this early stage it will allow you to create right click in a form to open the editor need to have Qt installed on your system small programs, and it was stable during (see Figure 4). to run your program. our tests. Program development is quick and Editing Source Code Help! painless due to the various GUI The source code editor may look The Gambas home page and the tools, and the footprint of the somewhat spartan at first glance (Figure subscription CD both include a executables Gambas creates is sur- 5). But try clicking the right mouse substantial language directory, the prisingly small. Future versions promise an enhanced debugger and a database GLOSSARY access component. ■ GUI: Graphical User Interface:This means the visual elements of a program, as the user sees them on screen. Syntax Highlighting: The editor uses colors to highlight commands,remarks,and variables, INFO allowing the developer to keep track more easily and recognize typos at a glance. Compiler: A compiler is a program that converts the source code authored by a developer into a [1] Project home page:http://gambas. machine-readable and executable format. sourceforge.net www.linux-magazine.com Dec 02 / Jan 03 85.