Content deleted Content added
Nothing to do with BASIC. |
m Moving Category:Software using the GPL license to Category:Software using the GNU General Public License per Wikipedia:Categories for discussion/Speedy |
||
(498 intermediate revisions by more than 100 users not shown) | |||
Line 1:
{{Short description|BASIC dialect}}
{{Distinguish|Free Basics}}
<!--{{Lowercase title}}-->
{{Infobox programming language
| name = FreeBASIC
| logo = Fblogo.gif
| screenshot = FreeBasic help.png
| paradigm = [[Procedural programming|Procedural]], [[Object-oriented programming|object-oriented]]
| designer = Andre Victor<ref>{{cite web|title=freeBASIC about page|url=https://www.freebasic.net/about.html|work=freeBASIC compiler|access-date=5 February 2012}}</ref>
| developer = The FreeBASIC Development Team
| latest release version = 1.10.1
| latest release date = {{start date and age|2023|12|25}}
| typing = [[Type system#Static typing|Static]]
| implementations =
| dialects =
| influenced by = [[QuickBASIC]], [[C (programming language)|C]]
| operating system = [[MS-DOS]], [[FreeBSD]], [[Linux]], [[Microsoft Windows]]
| license = [[GNU General Public License|GNU GPLv2+]], [[GNU Lesser General Public License|Standard libraries licensed under the GNU LGPLv2+]]
| website = {{URL|www.freebasic.net}}
| year = {{start date and age|2004}}
}}
'''FreeBASIC''' is a [[FOSS|free and open source]] multiplatform [[compiler]] and [[programming language]] based on [[BASIC]] licensed under the [[GNU General Public License|GNU GPL]] for [[Microsoft Windows]], protected-mode [[MS-DOS]] ([[DOS extender]]), [[Linux]], [[FreeBSD]] and [[Xbox (console)|Xbox]]. The Xbox version is no longer maintained.<ref>[http://www.freebasic.net/wiki/wikka.php?wakka=FaqPgxbox FBWiki : FaqPgxbox]</ref>
According to its official website,<ref>[http://www.freebasic.net/ freeBASIC Programming Language: Official Web site]</ref> FreeBASIC provides syntax compatibility with [[computer program|program]]s originally written in [[QuickBASIC|Microsoft QuickBASIC]] (QB). Unlike QuickBASIC, however, FreeBASIC is a command line only [[compiler]], unless users manually install an external [[integrated development environment]] (IDE) of their choice.<ref>{{cite web|title=freeBASIC official website downloads page|url=http://www.freebasic.net/gallery.html|work=freeBASIC compiler|access-date=13 May 2017}}</ref>
==Compiler features==
On its [[Front and back ends|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 (programming language)|C]] static and dynamic [[library (computing)|libraries]] and has limited support for [[C++]] libraries. As a result, code compiled in FreeBASIC can be reused in most native development environments.
While not an [[optimizing compiler]], FreeBASIC can optionally [[Source-to-source compiler|transcompile]] to C to compile with optimizations. FreeBASIC supports [[Inline assembler|inline assembly]], [[Multithreading (software)|multi-threading]], and does not use [[automatic garbage collection]].
[[C preprocessor|C style preprocessing]], including multiline [[macro (computer science)#Text-substitution macros|macros]], conditional compiling and file inclusion, is supported. The preprocessor also has access to symbol information and compiler settings, such as the [[Dialect (computing)|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.<ref>{{cite web|title=freeBASIC dialects|url=http://www.execulink.com/~coder/freebasic/compare.html|work=coderJeff's home page|access-date=5 February 2012}}</ref> New features include support for concepts such as [[object (computer science)|object]]s, [[operator overloading]], [[function overloading]], [[namespace]]s and others.<ref>{{cite web|title=Differences from QB|url=http://www.freebasic.net/wiki/wikka.php?wakka=LangQB|work=freeBASIC.net documentation|access-date=5 February 2012}}</ref>
[[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 (punctuation)|colon]] (:).
Block [[comment (computer programming)|comments]], as well as end-of-line remarks are supported. Full line comments are made with an [[apostrophe]] <code>'</code>, while blocks of commented code begin with <code>/'</code> and end with <code>'/</code>.
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 <code>SCREEN</code> command. Its backend defaults to [[OpenGL]] on [[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 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 interface#Arguments|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, <code>[[GOSUB]]</code> / <code>RETURN</code>, [[line number|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]] are done just as they were in QuickBASIC.
<syntaxhighlight lang="qbasic">
Print "Hello, World!"
sleep:end 'Comment, prevents the program window from closing instantly
</syntaxhighlight>
FreeBASIC adds to this with support for [[object-oriented programming|object-oriented]] features such as [[Method (computer programming)|methods]], [[constructor (object-oriented programming)|constructors]], [[Memory management#DYNAMIC|dynamic memory allocation]], [[property (programming)|properties]] and temporary allocation.
<syntaxhighlight lang="vbnet" highlight="1,11">
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
</syntaxhighlight>
<syntaxhighlight lang="vbnet">
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
</syntaxhighlight>
In both cases, the language is well suited for learning purposes.
==References==
{{reflist}}
==External links==
{{Commons and category}}
* {{Official website|www.freebasic.net}}
* {{github|freebasic/fbc|FreeBASIC}}
* {{sourceforge|fbc}}
;IDEs
* [https://github.com/PaulSquires/WinFBE WinFBE] - Modern FreeBASIC Editor for Windows
* [https://github.com/XusinboyBekchanov/VisualFBEditor/releases VisualFBEditor] - Cross-platform graphical IDE
* [http://fbide.freebasic.net/ fbide.freebasic.net] — FBIDE Integrated Development Environment for freeBASIC
* [https://www.freebasic-portal.de/downloads/ides-fuer-freebasic/fbedit-ide-30.html FBEdit (current)] — FBEdit source code editor for FreeBASIC, version 1.0.7.6c
* {{sourceforge|fbedit|FBEdit source code editor for freeBASIC (outdated version: 1.0.6.8)}}
{{BASIC}}
{{FOSS}}
{{DEFAULTSORT:Freebasic}}
[[Category:BASIC compilers]]
[[Category:Free and open source compilers]]
[[Category:Object-oriented programming languages]]
[[Category:Free computer libraries]]
[[Category:Self-hosting software]]
[[Category:Articles with example BASIC code]]
[[Category:Free software programmed in BASIC]]
[[Category:DOS software]]
[[Category:Programming tools for Windows]]
[[Category:Linux programming tools]]
[[Category:Programming languages created in 2004]]
[[Category:Software using the GNU General Public License]]
[[Category:Programming languages]]
[[Category:High-level programming languages]]
[[Category:2004 software]]
[[Category:BASIC programming language family]]
[[Category:Statically typed programming languages]]
|