Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

PureBasic

From Wikipedia, the free encyclopedia
Procedural computer programming language

This article includes a list ofgeneral references, butit lacks sufficient correspondinginline citations. Please help toimprove this article byintroducing more precise citations.(June 2011) (Learn how and when to remove this message)
PureBasic
ParadigmStructured,imperative,procedural
FamilyBASIC
Designed byFantaisie Software
DeveloperFantaisie Software
First appeared1998 (1998)
Stable release
6.30 / January 12, 2026; 38 days ago (2026-01-12)
OSWindows,Linux,macOS,Raspberry Pi OS,AmigaOS
LicenseTrialware
Filename extensions.pb, .pbi, .pbf, .pbp
Websitewww.purebasic.com
PureBasic IDE 5.10

PureBasic is acommercially distributedprocedural computerprogramming language andintegrated development environment based onBASIC and developed by Fantaisie Software forWindows,Linux,macOS andRaspberry Pi. AnAmiga version is available, although it has been discontinued and some parts of it arereleased 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.[1]

PureBasic compiles directly toIA-32,x86-64,arm32 andarm64,PowerPC or680x0 instruction sets, generating small standaloneexecutables andDLLs which need no runtime libraries beyond the standard system libraries. Programs developed without using the platform-specificapplication programming interfaces (APIs) can be built easily from the same source file with little or no modification.

PureBasic supportsinline assembly, allowing the developer to includeFASM 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 theOGRE 3D Environment. Other 3D environments such as theIrrlicht 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

[edit]

Characteristics

[edit]

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

[edit]

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 inlineWindows 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

[edit]

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 includesGoto, Gosub Label, andReturn.

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 withChr(34).

Object-oriented programming

[edit]

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

Data types

[edit]

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.
  • Len(String) used to count the length of a string will not exceed the firstnull character (Chr(0)).

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 theDimvar_name.type_name(size1,size2,...), alinked list (List()var_name.type_name), anassociative array (in new versions of language) (Map var_name.type_name())

Form Designer RAD

[edit]

PureBasic has its ownform designer to aid in the creation of forms for applications, but other third-party solutions are also available.[10][11] The original non-integratedVisual Designer was replaced with a new integratedForm Designer on 14 Feb 2013.[12]

User community

[edit]

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

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

Further reading

[edit]
  • Willoughby, Gary (2006).Purebasic: A Beginner s Guide to Computer Programming. Aardvark Global.ISBN 1-4276-0428-2.
  • Logsdon, John.Programming 2D Scrolling Games.This book is now freely downloadable
  • Basic Compilers: QuickBASIC, PureBasic, PowerBASIC, Blitz Basic, XBasic, Turbo Basic, Visual Basic, FutureBASIC, REALbasic, FreeBASIC.ISBN 1-155-32445-5.

References

[edit]
  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. ^PureBasic 5.10 is released
  13. ^English forum, Official forum.
  14. ^Horst Schaeffer's Software Pages
  15. ^PureArea
  16. ^Andre Beer's code archive.

General references

[edit]

External links

[edit]
Articles
Libraries and Open Source Code Archives
Dialects of theBASIC programming language (list)
Classic
Microsoft
Texas Instruments
Hewlett-Packard
Locomotive Software
Microcomputers
Minicomputers
Time-sharing computers
Other
Extenders
Procedure-
oriented
Proprietary
Free and
open source
Withobject
extensions
Proprietary
Free and
open source
RAD
designers
Proprietary
Free and
open source
Defunct
C,C++
Open source
Freeware
Retail
Discontinued
Java
Open source
Freeware
Retail
Discontinued
JavaScript
Open source
Haxe
CLI (.NET)
Open source
Freeware
Retail
Discontinued
Flash
PHP
Open source
Proprietary
R
Python
Open source
Proprietary
Pascal,
Object
Pascal
Open source
Freeware
Retail
Discontinued
BASIC
Open source
Freeware
Retail
Discontinued
Go
Open source
Freeware
Retail
Eiffel
POP-11
Online
Qt
Open source
GTK
Open source
Proprietary
wxWidgets
Open source
CLI
Open source
Proprietary
VCL,
related
Open source,LCL
Proprietary
Cocoa
Proprietary
Java-based
Open source
Proprietary
Windows API
Open source
Proprietary
Other
Open source
Proprietary
Retrieved from "https://en.wikipedia.org/w/index.php?title=PureBasic&oldid=1336538166"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp