Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
PureBasic
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Procedural computer programming language}} {{Use dmy dates|date=August 2020}} {{More footnotes needed|date=June 2011}} {{Infobox programming language | name = PureBasic | logo = | screenshot = PureBasic VD.png | caption = The PureBasic Visual Designer, showing a selection of popular GUI components that it supports. | paradigm = [[structured programming|Structured]], [[imperative programming|imperative]], [[procedural programming|procedural]] | family = [[BASIC]] | designer = Fantaisie Software | developer = Fantaisie Software | latest release version = 6.20 | latest release date = {{Start date and age|2025|02|12}} | typing = | year = {{Start date|1998}} | influenced = | license = [[Trialware]] | website = {{URL|www.purebasic.com}} | influenced_by = | operating_system = [[Windows]], [[Linux]], [[macOS]], [[Raspberry Pi OS]], [[AmigaOS]] | file_ext = .pb, .pbi, .pbf, .pbp }} [[File:PureBasic IDE 5.10.png|thumb|PureBasic IDE 5.10]] '''PureBasic''' is a [[commercial software|commercially distributed]] [[procedural programming|procedural]] computer [[programming language]] and [[integrated development environment]] based on [[BASIC]] and developed by Fantaisie Software for [[Microsoft Windows|Windows]], [[Linux]], [[macOS]] and [[Raspberry Pi]]. An [[Amiga]] version is available, although it has been discontinued and some parts of it are [[Open-source license|released as open-source]]. The first public release of PureBasic for Windows was on 17 December 2000. It has been continually updated ever since. PureBasic has a "lifetime license model". As cited on the website, the first PureBasic user (who registered in 1998) still has free access to new updates and this is not going to change.<ref name="Lifetime License">[http://www.purebasic.com/faq.php FAQ] lifetime licence details</ref> PureBasic compiles directly to [[IA-32]], [[x86-64]], [[PowerPC]] or [[68k|680x0]] instruction sets, generating small standalone [[executable]]s and [[dynamic-link library|DLLs]] which need no runtime libraries beyond the standard system libraries. Programs developed without using the platform-specific [[application programming interface]]s (APIs) can be built easily from the same source file with little or no modification. PureBasic supports [[inline assembly]], allowing the developer to include [[FASM]] assembler commands within PureBasic source code, while using the variables declared in PureBasic source code, enabling experienced programmers to improve the speed of speed-critical sections of code. PureBasic supports and has integrated the [[OGRE]] 3D Environment. Other 3D environments such as the [[Irrlicht Engine]] are unofficially supported. Since version 6.00 (June 2022), in addition to compilation using ASM, PureBasic offers compilation with a C backend. This enables access to new platforms (e.g. Raspberry) and should make it easier to add new libraries in the future. == Programming language == === Characteristics === PureBasic is a native cross platform 32 bit and 64 bit BASIC compiler. Currently supported systems are Windows, Linux, macOS. The AmigaOS version is legacy and open-source. The compiler produces native executables and the syntax of PureBasic is simple and straightforward, comparable to plain C without the brackets and with native unicode string handling and a large library of built-in support functions.<ref name="PureBasic home page">[http://www.purebasic.com/index.php PureBasic home page]</ref> It can compile console applications,<ref name="PureBasic - Console">[http://www.purebasic.com/documentation/console/index.html PureBasic - Console]</ref> GUI applications,<ref name="PureBasic - Gadget">[http://www.purebasic.com/documentation/gadget/index.html PureBasic - Gadget]</ref> and DLL files.<ref name="Building a DLL">[http://www.purebasic.com/documentation/reference/dll.html Building a DLL]</ref> === Hello World example === The following single line of PureBasic code will create a standalone x86 executable (4.5 KiB (4,608 bytes) on Windows version) that displays a message box with the text "[["Hello, World!" program|Hello World]]". <syntaxhighlight lang="blitzbasic"> MessageRequester("Message Box", "Hello World")</syntaxhighlight> And the following variant of the same code, which instead uses an inline [[Windows API]] call with no need for declarations or other external references, will create an even smaller 2.0 KiB (2,048 bytes) standalone x86 executable for Windows. <syntaxhighlight lang="blitzbasic"> MessageBox_(0, "Hello World", "Message Box", 0)</syntaxhighlight> The following is a console version of the Hello World example. <syntaxhighlight lang="blitzbasic"> OpenConsole() ; Open a console window. Print("Hello, World!") Delay(5000) ; Pause for 5 seconds</syntaxhighlight> === Procedural programming === PureBasic is a "Second generation BASIC" language, with structured conditionals and loops, and procedure-oriented programming supported. The user is not required to use procedures, so a programmer may opt for a coding style which includes {{mono|Goto, Gosub Label}}, and {{mono|Return}}. Below is a sample procedure for sorting an array, although SortArray is now a built-in function of PureBasic. <syntaxhighlight lang="blitzbasic" line highlight="1,15"> Procedure bubbleSort(Array a(1)) Protected i, itemCount, hasChanged itemCount = ArraySize(a()) Repeat hasChanged = #False itemCount - 1 For i = 0 To itemCount If a(i) > a(i + 1) Swap a(i), a(i + 1) hasChanged = #True EndIf Next Until hasChanged = #False EndProcedure</syntaxhighlight> Below is a sample program that displays a sizeable text editor with two menu items. <syntaxhighlight lang="blitzbasic"> ;Create Window: OpenWindow(0, #PB_Ignore, #PB_Ignore, 800, 600, "Simple Text Editor", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget) ;Add 2 menus: CreateMenu(0, WindowID(0)) MenuItem(1, "&OK") MenuItem(2, "&Cancel") ;Add Editor: EditorGadget(0, 0, 0, 0, 0) SetGadgetFont(0, LoadFont(0, "Courier New", 10)) ;Process window messages until closed: Repeat Select WaitWindowEvent() Case #PB_Event_Menu Select EventMenu() Case 1: MessageRequester("OK clicked directly or with '&' mnemonic.", GetGadgetText(0)) Case 2: Break EndSelect Case #PB_Event_SizeWindow: ResizeGadget(0, 0, 0, WindowWidth(0, #PB_Window_InnerCoordinate), WindowHeight(0, #PB_Window_InnerCoordinate)) Case #PB_Event_CloseWindow: Break EndSelect ForEver </syntaxhighlight> PureBasic does not escape double quotes in strings so these must be concatenated with {{mono|Chr(34)}}. === Object-oriented programming === Fred, the developer of PureBasic, has stated that PureBasic will never be [[Object-oriented programming|object oriented]].<ref name="PureBasic won't be object oriented">[http://www.purebasic.fr/english/viewtopic.php?p=403070#p403070 PureBasic won't be object oriented]</ref> However, numerous users have created object oriented support systems.<ref name="PureBasic Forum: PureObject - PureBasic OOP support">[http://www.purebasic.fr/english/viewtopic.php?t=30236 PureObject: PureBasic OOP support]</ref><ref name="PureBasic Forum: OOP tutorial added to the nxSoftware site!">[http://www.purebasic.fr/english/viewtopic.php?t=36255 OOP tutorial]</ref><ref name="PureBasic Forum: Another OOP PreCompiler">[http://www.purebasic.fr/english/viewtopic.php?t=30774 Another OOP PreCompiler]</ref> === Data types === Variable data type specified when you first use it (and optionally - in the future), and is separated from the name of the point. There is a set of basic types - {{mono|.f, .d}} (float and double numbers), {{mono|.b, .c, .w, .l, .q}} (integers - from single-byte and 8-byte), {{mono|.s}} - strings. {| class="wikitable" |- ! Type !! Suffix !! Memory usage !! Numerical range |- | Byte || {{mono|b}} || 1 byte (8 bits) || −128 ... +127 |- | Ascii || {{mono|a}} || 1 byte (8 bits) || 0 ... +255 |- | Character || {{mono|c}} || 1 byte (8 bits) (ascii) || 0 ... +255 |- | Word || {{mono|w}} || 2 bytes (16 bits) || −32768 ... +32767 |- | Unicode || {{mono|u}} || 2 bytes (16 bits) || 0 ... +65535 |- | Character || {{mono|c}} || 2 bytes (16 bits) (unicode) || 0 ... +65535 |- | Long || {{mono|l}} || 4 bytes (32 bits) || −2147483648 ... +2147483647 |- | Integer || {{mono|i}} || 4 bytes (32 bits) x86 || −2147483648 ... +2147483647 |- | Float || {{mono|f}} || 4 bytes (32 bits) || Depending on the ratio of the decimal number. |- | Integer || {{mono|i}} || 8 bytes (64 bits) x64 || −9223372036854775808 ... +9223372036854775807 |- | Quad || {{mono|q}} || 8 bytes (64 bits) || −9223372036854775808 ... +9223372036854775807 |- | Double || {{mono|d}} || 8 bytes (64 bits) || Depending on the ratio of the decimal number. |- | String || {{mono|s}} || (String length + 1) * [[sizeof|SizeOf]](Character) || No limit. |- | Fixed String || {{mono|s{length}}} || (String length) * SizeOf(Character) || No limit. |} * {{mono|Len(String)}} used to count the length of a string will not exceed the first [[null character]] ({{mono|Chr(0)}}). In addition to basic types, the user can define the type of construction via <syntaxhighlight lang="text"> Structure type_name field_name.type ; Single field. Perhaps the structures attachment. field_name[count].type ; Static arrays. ; ... ; Optional construction StructureUnion .. EndStructureUnion allows you ; to combine multiple fields into one area of memory ; that is sometimes required for the conversion types. StructureUnion type_name.type ; ... EndStructureUnion EndStructure </syntaxhighlight> Variables can be single (actually, standard variables), [[dynamic array]] (declared using the {{code|lang=blitzbasic|Dim var_name.type_name (size1, size2, ... )}}, a [[linked list]] ({{code|lang=blitzbasic|List() var_name.type_name}}), an [[associative array]] (in new versions of language) ({{code|Map var_name.type_name()}}) == Form Designer RAD == PureBasic has its own [[Form (programming)|form]] designer to aid in the creation of forms for applications, but other third-party solutions are also available.<ref name="Form design 1">[http://purevision.reelmedia.org/ PureVision], Professional form design for PureBASIC.</ref><ref name="Form design 2">[http://www.progui.co.uk/ ProGUI], DLL library comprising more than 100 well documented commands to quickly incorporate rich, customizable GUI components into your applications.</ref> The original non-integrated ''Visual Designer'' was replaced with a new integrated ''Form Designer'' on 14 Feb 2013.<ref name="PureBasic 5.10 is released !">[http://www.purebasic.fr/english/viewtopic.php?f=14&t=53464 PureBasic 5.10 is released]</ref> == User community == PureBasic provides an online forum for users to ask questions and share knowledge. On 17 february 2025 the English language forum had 6,484 members and contained 70,174 threads comprising 578,646 posts since 17 May 2002.<ref name="English forum">[http://www.purebasic.fr/english English forum], Official forum.</ref> Numerous code sharing sites show PureBasic is used to create tools<ref name="Tools 1">[http://www.horstmuc.de/win.htm Horst Schaeffer's Software Pages]</ref> and games in a fast and easy way,<ref name="PureArea">[http://www.purearea.net/ PureArea]</ref> and share large amounts of open-source code.<ref name="Code snippets">[http://www.purearea.net/pb/CodeArchiv/English.html Andre Beer's code archive.]</ref> == Further reading == * {{cite book|last=Willoughby|first=Gary|title=Purebasic: A Beginner s Guide to Computer Programming|year=2006|publisher=Aardvark Global |isbn=1-4276-0428-2}} * {{cite book|last=Logsdon|first=John|title=Programming 2D Scrolling Games}}[http://www.purebasic.fr/english/viewtopic.php?f=14&t=58232 This book is now freely downloadable] * {{cite book|isbn=1-155-32445-5|title=Basic Compilers: QuickBASIC, PureBasic, PowerBASIC, Blitz Basic, XBasic, Turbo Basic, Visual Basic, FutureBASIC, REALbasic, FreeBASIC }} == References == {{Reflist}} === General references=== * {{cite book|last=Hale Ligh|first=Michael |title=Malware Analysts Cookbook Tools for Thwarting Malicious Attacks.|year=2010|publisher=John Wiley & Sons Inc|location=Indianapolis, IN|isbn=978-0-470-61303-0|pages=241}} * {{cite book|last=Galbreath|first=Nick|title=Cryptography for Internet and database applications : developing secret and public key techniques with Java|year=2002|publisher=Wiley|location=Indianapolis, Ind.|isbn=978-0-471-21029-0|pages=[https://archive.org/details/cryptographyfori00galb/page/300 300]|url-access=registration|url=https://archive.org/details/cryptographyfori00galb/page/300}} * {{cite news|title=Learning to Crack Code|url=https://i.imgur.com/0jZ8noC.jpg/|newspaper=[[Manly Daily]]|date=25 June 2004}} * {{cite journal|last=Georges|first=Philippe|title=La programmation avec PureBasic|journal=PROgrammez|issue=141|url=http://www.programmez.com/magazine_articles.php?titre=La-programmation-avec-PureBasic&id_article=1538&magazine=141}} * {{cite book|last=Svoboda|first=Luboš|title=Překvapivý PureBasic (Surprising PureBasic: A Czech ebook for prospective users of PureBasic)|year=2012|pages=89|url=http://people.fsv.cvut.cz/~svobodal/pure/index.htm}} == External links == * {{official website|http://www.purebasic.com}} * [https://www.purebasic.fr/english/ Official Purebasic Forums (English)] * [https://www.purebasic.fr/blog/ PureBasic Team Blog] - Official Blog "Random thoughts on PureBasic development" ;Articles * [http://www.codeproject.com/Articles/853831/PureBasic-The-Perfect-Cross-Platform-Native-Develo PureBasic - The Perfect Cross-Platform & Native Development Language] (2015) ;Libraries and Open Source Code Archives * [http://www.purearea.net/pb/CodeArchiv/English.html Andre Beer's Open Source PB code archive] {{BASIC}} {{Integrated development environments}} {{GUI builders}} {{DEFAULTSORT:Purebasic}} [[Category:1998 software]] [[Category:BASIC compilers]] [[Category:BASIC programming language family]] [[Category:High-level programming languages]] [[Category:Integrated development environments]] [[Category:Linux integrated development environments]] [[Category:MacOS programming tools]] [[Category:Procedural programming languages]] [[Category:Programming languages]] [[Category:Programming languages created in 1998]] [[Category:User interface builders]] [[Category:Windows integrated development environments]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:BASIC
(
edit
)
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite news
(
edit
)
Template:Code
(
edit
)
Template:GUI builders
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Integrated development environments
(
edit
)
Template:Mono
(
edit
)
Template:More footnotes needed
(
edit
)
Template:Official website
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Use dmy dates
(
edit
)