FreeBASIC

Not to be confused with Free Basics.
FreeBASIC
Paradigm Procedural, object-oriented
Designed by Andre Victor[1]
Developer The FreeBASIC Development Team
First appeared 2004 (2004)
Stable release 1.04.0 / October 1, 2015 (2015-10-01)
Typing discipline Static
OS DOS, FreeBSD, Linux, Microsoft Windows
License GNU GPL, Standard libraries licensed under the GNU LGPL
Website www.freebasic.net
Influenced by
QuickBASIC, C

FreeBASIC is a multiplatform, free/open source (GPL) BASIC compiler[2] for Microsoft Windows, protected-mode DOS (DOS extender), Linux, FreeBSD and Xbox. The Xbox version is no longer maintained.[3]

According to its official website,[4] FreeBASIC provides syntax compatibility with programs originally written in QuickBASIC. Unlike QuickBASIC, however, FreeBASIC is a command line only compiler, unless users manually install an external IDE of their choice.[5] IDEs specifically made for FreeBASIC include FBide and FbEdit.

Compiler features

On its backend, FreeBASIC makes use of GNU binutils in order to produce console and GUI applications. FreeBASIC supports the linking and creation of C static and dynamic libraries and has limited support for C++ libraries. As a result, code compiled in FreeBASIC can be reused in most native development environments.

C style preprocessing, including multiline macros, conditional compiling and file inclusion, is supported. The preprocessor also has access to symbol information and compiler settings, such as the language dialect.

Syntax

Initially, FreeBASIC emulated QBASIC syntax as closely as possible. Beyond that, the language has continued its evolution. As a result, FreeBASIC combines several language dialects for maximum level of compatibility with QBASIC in one side, and full access to modern features in one other.[6] New features include now support for types as objects, operator overloading, function overloading, namespaces and others.[7]

End-of-line characters indicate the termination of programming statements. A programming statement can be distributed on multiple consecutive lines by using the line continuation char _, whereas multiple statements may be written on a single line by separating each statement with a colon :.

FreeBASIC supports block commenting as well as end of line remarks. Full line comments are made with an apostrophe ', while blocks of commented code begin with /' and end with '/.

FreeBASIC is not case sensitive.

Graphics library

FreeBASIC provides built-in, QuickBASIC compatible graphics support through FBgfx, which is automatically included into programs that make a call to the SCREEN command. Its backend defaults to OpenGL on GNU/Linux and DirectX on Microsoft Windows. This abstraction makes FBgfx graphics code cross-platform compatible. However, FBgfx is not hardware accelerated.

Users familiar with external graphics utilities such as OpenGL or the Windows API can use them without interfering with the built-in graphics library.

Language dialects

As FreeBASIC has evolved, changes have been made which required breaking older-styled syntax. In order to continue supporting programs written using the older syntax, FreeBASIC now supports the following dialects:

Example code

Standard programs, such as the hello, world program are done just as they were in QuickBASIC.

Print "Hello World"

sleep:end 'Comment, prevents the program window from closing instantly

FreeBASIC adds to this with support for object-oriented features such as methods, constructors, dynamic memory allocation, properties and temporary allocation.

Type Vector
    Private:
        x As Integer
        y As Integer
    Public:
        Declare Constructor (nX As Integer = 0, nY As Integer = 0)
        Declare Property getX As Integer
        Declare Property getY As Integer
End Type
 
Constructor Vector (nX As Integer, nY As Integer)
    x = nX
    y = nY
End Constructor
 
Property Vector.getX As Integer
    Return x
End Property
 
Property Vector.getY As Integer
    Return y
End Property
 
Dim As Vector Ptr player = New Vector()

*player = Type<Vector>(100, 100)
Print player->getX
Print player->getY

Delete player

Sleep 'Prevents the program window from closing instantly

In both cases, the language is well suited for learning purpose.

References

  1. "FreeBASIC about page". FreeBASIC compiler. Retrieved 5 February 2012.
  2. Lee Seats. "FreeBASIC the Successor to QuickBASIC". About.com. Retrieved 2008-08-17.
  3. FBWiki : FaqPgxbox
  4. FreeBASIC Programming Language: Official Website
  5. "FreeBASIC official website downloads page". FreeBASIC compiler. Retrieved 5 February 2012.
  6. "FreeBASIC dialects". coderJeff's home page. Retrieved 5 February 2012.
  7. "Differences between QBASIC and FreeBASIC". FreeBASIC.net documentation. Retrieved 5 February 2012.

External links

Wikimedia Commons has media related to:
IDEs
This article is issued from Wikipedia - version of the Monday, November 23, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.