PureBasic
PureBasic is a commercially distributed procedural computer programming language and integrated development environment based on BASIC and developed by Fantaisie Software for Windows 32/64-bit, Linux 32/64-bit, and macOS. An Amiga version is available, although it has been discontinued and some parts of it are released as open source. The first public release of PureBasic for Windows was on December 17, 2000. It has been continually updated since.
PureBasic has a "lifetime license model". As cited on the website, the first PureBasic user still has free access to new updates and this is not going to change.
PureBasic compiles directly to x86, x86-64, PowerPC or 680x0 instruction sets, generating small standalone executables and DLLs which need no runtime libraries beyond the standard system libraries. Programs developed without using the platform-specific application programming interfaces 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.
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 build-in support functions. It can compile console applications, GUI applications, and DLL files.Hello World example
The following single line of PureBasic code will create a standalone x86 executable that displays a message box with the text "Hello World".MessageRequester
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 standalone x86 executable for Windows.
MessageBox_
The following is a console version of the Hello World example.
OpenConsole ; Open a console window.
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, and.Below is a sample procedure for sorting an array, although SortArray is now a built-in function of PureBasic.
Procedure bubbleSort
Protected i, itemCount, hasChanged
itemCount = ArraySize)
Repeat
hasChanged = #False
itemCount - 1
For i = 0 To itemCount
If a > a
Swap a, a
hasChanged = #True
EndIf
Next
Until hasChanged = #False
EndProcedure
Below is a sample program that displays a sizeable text editor with two menu items.
;Create Window:
OpenWindow
;Add 2 menus:
CreateMenu
MenuItem
MenuItem
;Add Editor:
EditorGadget
SetGadgetFont
;Process window messages until closed:
Repeat
Select WaitWindowEvent
Case #PB_Event_Menu
Select EventMenu
Case 1: MessageRequester
Case 2: Break
EndSelect
Case #PB_Event_SizeWindow: ResizeGadget, WindowHeight)
Case #PB_Event_CloseWindow: Break
EndSelect
ForEver
Note that PureBasic does not escape double quotes in strings so these must be concatenated with.
Object-oriented programming
Fred, the developer of PureBasic, has stated that PureBasic will never be object oriented. However, numerous users have created object oriented support systems.Data types
Variable data type specified when you first use it, and is separated from the name of the point. There is a set of basic types - , , - strings.Type | Suffix | Memory usage | Numerical range |
Byte | 1 byte | −128... +127 | |
Ascii | 1 byte | 0... +255 | |
Character | 1 byte | 0... +255 | |
Word | 2 bytes | −32768... +32767 | |
Unicode | 2 bytes | 0... +65535 | |
Character | 2 bytes | 0... +65535 | |
Long | 4 bytes | −2147483648... +2147483647 | |
Integer | 4 bytes x86 | −2147483648... +2147483647 | |
Float | 4 bytes | Depending on the ratio of the decimal number. | |
Integer | 8 bytes x64 | −9223372036854775808... +9223372036854775807 | |
Quad | 8 bytes | −9223372036854775808... +9223372036854775807 | |
Double | 8 bytes | Depending on the ratio of the decimal number. | |
String | * SizeOf | No limit. | |
Fixed String | * SizeOf | No limit. |
- Note: used to count the length of a string will not exceed the first null character.
Structure type_name
field_name.type ; Single field. Perhaps the structures attachment.
field_name.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
Variables can be single, dynamic array, an associative array
Form Designer RAD
PureBasic has its own form designer to aid in the creation of forms for applications, but other third-party solutions are also available. The original non-integrated Visual Designer was replaced with a new integrated Form Designer on 14 Feb, 2013.User community
PureBasic provides an online forum for users to ask questions and share knowledge. On 6 May 2013 the English language forum had 4,769 members and contained 44,043 threads comprising 372,200 posts since May 17, 2002.Numerous code sharing sites show PureBasic is used to create tools and games in a fast and easy way, and share large amounts of open-source code.