HOME

TheInfoList



OR:

FreeBASIC is a free and open source multiplatform
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
and
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming l ...
based on
BASIC BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
licensed under the
GNU GPL The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the four freedoms to run, study, share, and modify the software. The license was the first copyleft for general ...
for Microsoft Windows, protected-mode
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few oper ...
( DOS extender),
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
, FreeBSD and Xbox. The Xbox version is no longer maintained. According to its official website, FreeBASIC provides syntax compatibility with programs originally written in Microsoft QuickBASIC (QB). Unlike QuickBASIC, however, FreeBASIC is a command line only
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
, unless users manually install an external
integrated development environment An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools a ...
(IDE) of their choice. IDEs specifically made for FreeBASIC include FBide and FbEdit, while more graphical options include WinFBE Suite and VisualFBEditor.


Compiler features

On its backend, FreeBASIC makes use of GNU Binutils in order to produce console and graphical user interface 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 Microsoft QuickBASIC 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 QuickBASIC and full access to modern features. New features include support for concepts such as objects, operator overloading, function overloading, namespaces and others. Newline characters indicate the termination of programming statements. A programming statement can be distributed on multiple consecutive lines by using the underscore ''line continuation char'' (_), whereas multiple statements may be written on a single line by separating each statement with a colon (:). Block
comments Comment may refer to: * Comment (linguistics) or rheme, that which is said about the topic (theme) of a sentence * Bernard Comment (born 1960), Swiss writer and publisher Computing * Comment (computer programming), explanatory text or informa ...
, as well as end-of-line remarks are supported. Full line comments are made with an
apostrophe The apostrophe ( or ) is a punctuation mark, and sometimes a diacritical mark, in languages that use the Latin alphabet and some other alphabets. In English, the apostrophe is used for two basic purposes: * The marking of the omission of one ...
', 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 OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve ha ...
on
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
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 that required breaking older-styled syntax. In order to continue supporting programs written using the older syntax, FreeBASIC now supports the following dialects: * The default dialect (''-lang fb'' as a command-line argument) supports all new compiler features and disallows archaic syntax. * The FB-lite dialect (''-lang fblite'') permits use of most new, non-object-oriented features in addition to older-style programming. Implicit variables, suffixes, GOSUB / RETURN, numeric labels and other features are allowed in this dialect. * The QB dialect (''-lang qb'') attempts to replicate QuickBASIC behavior and is able to compile many QuickBASIC programs without modification.


Example code

Standard programs, such as the
"Hello, World!" program A "Hello, World!" program is generally a computer program that ignores any input and outputs or displays a message similar to "Hello, World!". A small piece of code in most general-purpose programming languages, this program is used to illustr ...
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 Object-oriented programming (OOP) is a programming paradigm based on the concept of " objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
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(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 purposes.


References


External links

* * * ;IDEs
WinFBE
- Modern FreeBASIC Editor for Windows
VisualFBEditor
- Cross-platform graphical IDE
fbide.freebasic.net
nbsp; — FBIDE Integrated Development Environment for freeBASIC

nbsp; — FBEdit source code editor for FreeBASIC, version 1.0.7.6c * {{DEFAULTSORT:Freebasic BASIC compilers Free compilers and interpreters Object-oriented programming languages Free computer libraries Self-hosting software Articles with example BASIC code Free software programmed in BASIC DOS software Programming tools for Windows Linux programming tools Programming languages created in 2004 Software using the GPL license Programming languages High-level programming languages 2004 software BASIC programming language family