PureBasic

Last updated

PureBasic
PureBasic VD.png
Paradigm Structured, imperative, procedural
Family BASIC
Designed by Fantaisie Software
Developer Fantaisie Software
First appeared1998 (1998)
Stable release
6.10 LTS / March 27, 2024;13 days ago (2024-03-27)
OS Windows, Linux, macOS, Raspberry Pi OS, AmigaOS
License Trialware
Filename extensions .pb, .pbi, .pbf, .pbp
Website www.purebasic.com
PureBasic IDE 5.10 PureBasic IDE 5.10.png
PureBasic IDE 5.10

PureBasic is a commercially distributed procedural computer programming language and integrated development environment based on BASIC and developed by Fantaisie Software for Windows, Linux, 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 17 December 2000. It has been continually updated ever since.

Contents

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. [1]

PureBasic compiles directly to IA-32, 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 (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.

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. [2] It can compile console applications, [3] GUI applications, [4] and DLL files. [5]

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".

MessageRequester("Message Box","Hello World")

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.

MessageBox_(0,"Hello World","Message Box",0)

The following is a console version of the Hello World example.

OpenConsole(); Open a console window. Print("Hello, World!")Delay(5000); Pause for 5 seconds

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 Goto, Gosub Label, and Return.

Below is a sample procedure for sorting an array, although SortArray is now a built-in function of PureBasic.

ProcedurebubbleSort(Arraya(1))Protectedi,itemCount,hasChangeditemCount=ArraySize(a())RepeathasChanged=#FalseitemCount-1Fori=0ToitemCountIfa(i)>a(i+1)Swapa(i),a(i+1)hasChanged=#TrueEndIfNextUntilhasChanged=#FalseEndProcedure

Below is a sample program that displays a sizeable text editor with two menu items.

;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:RepeatSelectWaitWindowEvent()Case#PB_Event_MenuSelectEventMenu()Case1:MessageRequester("OK clicked directly or with '&' mnemonic.",GetGadgetText(0))Case2:BreakEndSelectCase#PB_Event_SizeWindow:ResizeGadget(0,0,0,WindowWidth(0,#PB_Window_InnerCoordinate),WindowHeight(0,#PB_Window_InnerCoordinate))Case#PB_Event_CloseWindow:BreakEndSelectForEver

PureBasic does not escape double quotes in strings so these must be concatenated with Chr(34).

Object-oriented programming

Fred, the developer of PureBasic, has stated that PureBasic will never be object oriented. [6] However, numerous users have created object oriented support systems. [7] [8] [9]

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 - .f, .d (float and double numbers), .b, .c, .w, .l, .q (integers - from single-byte and 8-byte), .s - strings.

TypeSuffixMemory usageNumerical range
Byteb1 byte (8 bits)−128 ... +127
Asciia1 byte (8 bits)0 ... +255
Characterc1 byte (8 bits) (ascii)0 ... +255
Wordw2 bytes (16 bits)−32768 ... +32767
Unicodeu2 bytes (16 bits)0 ... +65535
Characterc2 bytes (16 bits) (unicode)0 ... +65535
Longl4 bytes (32 bits)−2147483648 ... +2147483647
Integeri4 bytes (32 bits) x86−2147483648 ... +2147483647
Floatf4 bytes (32 bits)Depending on the ratio of the decimal number.
Integeri8 bytes (64 bits) x64−9223372036854775808 ... +9223372036854775807
Quadq8 bytes (64 bits)−9223372036854775808 ... +9223372036854775807
Doubled8 bytes (64 bits)Depending on the ratio of the decimal number.
Strings(String length + 1) * SizeOf(Character)No limit.
Fixed Strings{length}(String length) * SizeOf(Character)No limit.

In addition to basic types, the user can define the type of construction via

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 

Variables can be single (actually, standard variables), dynamic array (declared using the Dimvar_name.type_name(size1,size2,...), a linked list (List()var_name.type_name), an associative array (in new versions of language) (Map var_name.type_name())

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. [10] [11] [12] The original non-integrated Visual Designer was replaced with a new integrated Form Designer on 14 Feb 2013. [13]

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 17 May 2002. [14]

Numerous code sharing sites show PureBasic is used to create tools [15] and games in a fast and easy way, [16] and share large amounts of open-source code. [17]

Further reading

Related Research Articles

Turbo Pascal is a software development system that includes a compiler and an integrated development environment (IDE) for the programming language Pascal running on the operating systems CP/M, CP/M-86, and DOS. It was originally developed by Anders Hejlsberg at Borland, and was notable for its very fast compiling. Turbo Pascal, and the later but similar Turbo C, made Borland a leader in PC-based development tools.

<span class="mw-page-title-main">Liberty BASIC</span>

Liberty BASIC (LB) is a commercial computer programming language and integrated development environment (IDE). It has an interpreter, developed in Smalltalk, which recognizes its own dialect of the BASIC programming language. It runs on 16- and 32-bit Windows and OS/2.

<span class="mw-page-title-main">PowerBASIC</span> Software compiler

PowerBASIC, formerly Turbo Basic, is the brand of several commercial compilers by PowerBASIC Inc. that compile a dialect of the BASIC programming language. There are both MS-DOS and Windows versions, and two kinds of the latter: Console and Windows. The MS-DOS version has a syntax similar to that of QBasic and QuickBASIC. The Windows versions use a BASIC syntax expanded to include many Windows functions, and the statements can be combined with calls to the Windows API.

<span class="mw-page-title-main">Windows API</span> Microsofts core set of application programming interfaces on Windows

The Windows API, informally WinAPI, is the foundational application programming interface (API) that allows a computer program to access the features of the Microsoft Windows operating system in which the program is running.

<span class="mw-page-title-main">Visual Basic (.NET)</span> Object-oriented computer programming language

Visual Basic (VB), originally called Visual Basic .NET (VB.NET), is a multi-paradigm, object-oriented programming language, implemented on .NET, Mono, and the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to its original Visual Basic language, the last version of which was Visual Basic 6.0. Although the ".NET" portion of the name was dropped in 2005, this article uses "Visual Basic [.NET]" to refer to all Visual Basic languages released since 2002, in order to distinguish between them and the classic Visual Basic. Along with C# and F#, it is one of the three main languages targeting the .NET ecosystem. Microsoft updated its VB language strategy on 6 February 2023, stating that VB is a stable language now and Microsoft will keep maintaining it.

<span class="mw-page-title-main">Delphi (software)</span> General-purpose programming language and a software product

Delphi is a general-purpose programming language and a software product that uses the Delphi dialect of the Object Pascal programming language and provides an integrated development environment (IDE) for rapid application development of desktop, mobile, web, and console software, currently developed and maintained by Embarcadero Technologies.

Object Pascal is an extension to the programming language Pascal that provides object-oriented programming (OOP) features such as classes and methods.

xHarbour is a free multi-platform extended Clipper compiler, offering multiple graphic terminals (GTs), including console drivers, GUIs, and hybrid console/GUIs. xHarbour is backward-compatible with Clipper and supports many language syntax extensions, greatly extended run-time libraries, and extensive third party support.

<span class="mw-page-title-main">Visual Prolog</span>

Visual Prolog, previously known as PDC Prolog and Turbo Prolog, is a strongly typed object-oriented extension of Prolog. As Turbo Prolog, it was marketed by Borland but it is now developed and marketed by the Danish firm PDC that originally created it. Visual Prolog can build Microsoft Windows GUI-applications, console applications, DLLs, and CGI-programs. It can also link to COM components and to databases by means of ODBC.

Harbour is a computer programming language, primarily used to create database/business programs. It is a modernized, open source and cross-platform version of the older Clipper system, which in turn developed from the dBase database market of the 1980s and 1990s.

thinBasic is a BASIC-like computer programming language interpreter with a central core engine architecture surrounded by many specialized modules. Although originally designed mainly for computer automation, thanks to its modular structure it can be used for wide range of tasks.

<span class="mw-page-title-main">AutoIt</span>

AutoIt is a freeware programming language for Microsoft Windows. In its earliest release, it was primarily intended to create automation scripts for Microsoft Windows programs but has since grown to include enhancements in both programming language design and overall functionality.

In computer programming, the term hooking covers a range of techniques used to alter or augment the behaviour of an operating system, of applications, or of other software components by intercepting function calls or messages or events passed between software components. Code that handles such intercepted function calls, events or messages is called a hook.

The Microsoft Windows operating system supports a form of shared libraries known as "dynamic-link libraries", which are code libraries that can be used by multiple processes while only one copy is loaded into memory. This article provides an overview of the core libraries that are included with every modern Windows installation, on top of which most Windows applications are built.

<span class="mw-page-title-main">Visual Basic (classic)</span> Microsofts programming language based on BASIC and COM

Visual Basic (VB) before .NET, sometimes referred to as Classic Visual Basic, is a third-generation programming language, based on BASIC, and an integrated development environment (IDE), from Microsoft for Windows known for supporting rapid application development (RAD) of graphical user interface (GUI) applications, event-driven programming and both consumption and development of components via the Component Object Model (COM) technology.

<span class="mw-page-title-main">Cosmos (operating system)</span> Toolkit for building GUI and command-line based operating systems

C# Open Source Managed Operating System (Cosmos) is a toolkit for building GUI and command-line based operating systems, written mostly in the programming language C# and small amounts of a high-level assembly language named X#. Cosmos is a backronym, in that the acronym was chosen before the meaning. It is open-source software released under a BSD license.

<span class="mw-page-title-main">FutureBASIC</span>

FutureBasic is a free BASIC compiler for Apple Inc.'s Macintosh.

XBLite is a free Open Source BASIC programming language compiler and development system. It was started in 2001 by David Szafranski in order to provide a Windows exclusive version of the XBasic dialect. XBLite is released under the GNU GPL licensing scheme, Standard libraries are released under the GNU LGPL licensing scheme.

Proteus is a fully functional, procedural programming language created in 1998 by Simone Zanella. Proteus incorporates many functions derived from several other languages: C, BASIC, Assembly, Clipper/dBase; it is especially versatile in dealing with strings, having hundreds of dedicated functions; this makes it one of the richest languages for text manipulation.

Absoft Fortran Compilers are set of Fortran compilers for Microsoft Windows, Apple Macintosh, and Linux produced by Absoft Corporation. The compilers are source code compatible across platforms.

References

  1. FAQ lifetime licence details
  2. PureBasic home page
  3. PureBasic - Console
  4. PureBasic - Gadget
  5. Building a DLL
  6. PureBasic won't be object oriented
  7. PureObject: PureBasic OOP support
  8. OOP tutorial
  9. Another OOP PreCompiler
  10. PureVision, Professional form design for PureBASIC.
  11. ProGUI, DLL library comprising more than 100 well documented commands to quickly incorporate rich, customizable GUI components into your applications.
  12. PureFORM, Freeware form designer.
  13. PureBasic 5.10 is released
  14. English forum, Official forum.
  15. Horst Schaeffer's Software Pages
  16. PureArea
  17. Andre Beer's code archive.

General references

Articles
Libraries and Open Source Code Archives