GAMBAS - Gambas Almost Means Basic! (Linux Bangalore 2004)

GAMBAS - Gambas Almost Means Basic! (Linux Bangalore 2004)

GAMBAS - Gambas Almost Means BASic! (Linux Bangalore 2004) Nalini Vasudevan ∗ Arjun Jain † 1 Introduction Gambas is a Linux replacement for Visual Ba- sic (but by no means it’s clone). It is a free development software based on a Basic in- terpreter. To put it in short, it is a Basic Language with object extensions. If a RAD tool is required for say designing a GUI or a front-end to access MySQL or PostgreSQL databases, then Gambas is the tool. KDE pi- lot application and network applications (with the Gambas Network ToolBox) can also be designed. Also Gambas has multilingual sup- port and thus a program can be translated into many languages. Gambas was not designed to be a VB clone, Figure 1: ‘How Gambas Works’ but a “better” Visual Basic like tool for the Linux environment. Gambas is not compati- interpreter. ble with Visual basic and will never be.. Gambas comprises of a Compiler, an In- 2 Gambas - Features terpreter, an Archiver, a Graphical User Interface component and a Development The main advantage of Gambas is that it has Environment. a component architecture. This allows exten- A program written in Gambas has a number sion. We can write our own components as of classes, each described in a file.It uses the shared libraries that can be added dynami- concept of Object programming. The .class cally. This architecture is useful for writing files are compiled and then executed by an the GUI of the language. In fact, the Gam- bas interpreter is a text only program and ∗R.V. College of Engineering, Computer Science & the graphical interface itself is implemented Engineering, Bangalore, India 560059 Tel: +91 94481 as a Gambas-Qt component. The advantage 07482 Email: [email protected] †R.V. College of Engineering, Computer Science & is that Gambas can me made independent of Engineering, Bangalore, India 560059 Tel: +91 94483 any tool kit! A Gambas program can first 74482 Email: [email protected] be written and then the toolkit can be chosen later.(of course the toolkit needs to be written first ) A Gambas project is stored under one direc- tory. The project directory structure is trans- formed into one sole executable file by the archiver. Only the modified classes are com- piled during compilation. External references of a class are solved dynamically at the execu- tion time. Finally, Gambas projects are easily translatable, in any language. 3 Gambas - Architecture The Development Environment hides this ma- chinery behind a pretty graphical interface. 3.1 Interpreter The interpreter is a program named gbx. It executes the byte code of the compiled file generated by the compiler. 3.2 Project A project is a set of files stored in one di- rectory. A project can contain source files (forms, classes, modules) or any data files of any types. The project configuration is stored Figure 2: The Gambas Architecture in a file named “.project”. 3.3 Native Classes 3.5 Components The native classes can be used without load- Components are shared libraries that are ing any component. They are integrated in loaded at run time by the interpreter. They the interpreter, and can be looked upon as a can contain new classes and hook routines part of the Gambas language. such as event loop management, shell argu- ments analyze, etc. They can publish a set of routines as an interface to other components. 3.4 Component Interface 3.6 Execution Unit The Component Interface is a set of routines and services used by the components to com- The execution unit is the heart of the inter- municate with the interpreter. The inter- preter. It dispatches and executes each byte- preter’s internals are hidden this way. code instruction generated by the compiler. 2 3.7 Subroutines 3.13 The Component Loader The subroutines are the interpreter functions The Component Loader is the part of the associated to the corresponding Gambas Ba- interpreter that loads components shared li- sic functions like Sin( ), Left$( ), etc. or op- braries, gives them access to the Component erators like +, &, etc. Interface, and that publishes their interface to other components. 3.8 Class Loader The Class Loader loads compiled forms, 4 Gambas v/s Microsoft Visual classes and modules into the interpreter. If Basic your project was compiled as an executable, i.e. as an archive, the interpreter maps the Gambas is not just a replica of Visual Basic. file into memory instead of loading it. So, you can not expect to simply copy your VB code and compile it under Gambas. This 3.9 Executable file is a great tool for VB developers and people wanting to port their legacy VB projects to A Gambas executable file is just an uncom- the Linux environment. There are perhaps pressed archive of your project, the compiled more similarities than differences and one to files included. The archive file is marked as a one relations between VB and Gambas, but script with the the differences are the ones that need more attention. "#!/usr/bin/gbx" 4.1 Non-Language-Specific Differences magic header, so that Linux executes it by • VB embeds the class code for each form calling the interpreter. object into the same file as the form def- inition. Gambas keeps them separate, in 3.10 Compiled files a .form and a .class file A compiled file is a binary representation of File extensions: a class, that contains all information useful VB Gambas Type of File to the interpreter : functions transformed to .vbp .project Project definition file byte code, constants, variables definitions, de- .bas .module Module bugging information, etc. .cls .class Class File .frm .form Form defn file 3.11 The Archiver .frx (anything) Binary files The archiver is a program named gba. It • Gambas projects are defined as a direc- transforms your project, the compiled files in- tory with a .project file in it, and all of cluded, in one “sole executable file”. the files in that directory. VB can have 3.12 The Compiler multiple project files in each directory and can pull the same source file from a The compiler is a program named gbc. It different directory into different projects, transforms your project’s forms, classes and which has its benefits and disadvantages. modules files into binary compiled files that can be understood by the interpreter. • Screen measurements in VB are done in 3 “twips”, units of 1/1440 of an inch; in turned on, which makes for much better Gambas they’re done in actual pixels. code at the expense of a bit more work. • Form controls in Gambas programs are • There’s no direct Gambas equivalent to private by default. This can be changed the Index property of VB form con- by going into the Project Properties dia- trols. Arrays of controls can be created log and checking the Make Form Controls easily, but it has to be done in code. Public checkbox. There’s currently no way to do it graph- ically. Thus, when a control is copied • Str$(), Val(), CStr()... conversion func- and pasted back on the form it came tions behave differently. For example, from, rather than prompting you to cre- Str$() and Val() use the localization set- ate a control array it automatically re- tings in Gambas, whereas they don’t in names the copied control to an appropri- Visual Basic. Note that Gambas behav- ate name. ior is more logical :-) • Currently transparent labels can’t be cre- 4.2 VB Has It, Gambas Doesn’t ated in Gambas; the background is al- ways opaque. • Currently code can’t be edited in Break mode in Gambas; the program needs to • The MouseMove event only occurs when be terminated first. a mouse button is depressed in Gambas. The exception is the DrawingArea con- • In Gambas, simple datatypes (integer, trol, which has a Tracking property that string, etc.) are passed by value to pro- allows getting mouse move events even if cedures and functions. They cannot be no mouse button is pressed. passed by reference as in Visual Basic. Note that VB passes parameters by ref- • In VB two strings can be put together erence if the ByVal keyword is not used. with the symbol + . Because the + sign Also, the contents of object datatypes is only used for mathematical addition (array types, collections, objects) are al- in Gambas, ‘&’ should instead be used, ways passed by reference in both lan- when one string needs to be added to an- guages! other string. • There is no such thing as a project- • In the print command the colon ‘:’ does wide global variable in Gambas. (As a not work to separate the code. A new- workaround, a class called Global can be line must be taken instead. The print created and global variables can be de- command in VB 3.0 did not make a Line- clared as static public variables in that feed. If it was used it to print out some class, and then they can be referred to as text with printer.print, then text got lost. global variablename in your project.) The Print Command in Gambas puts ev- erything in one line. There is nothing • Unless Option Explicit is included in a lost. VB module, variables need not be de- clared prior to using them. Gambas be- • In VB, Mid$() can be used as an instruc- haves as if Option Explicit were always tion to cut out a substring and put in 4 some other. In Gambas, it can not used makes it incredibly easy to write Gambas it to assign a new substring. For exam- front-ends for almost any command-line ple, in VB: MyString = “the dog jumps”: procedure.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us