PureBasic is a programming language like BASIC compiled.
Several points characterize it:
- Simplicity: BASIC syntax is simple to learn.
- Speed: the applications produced are optimized (reduced size) and fast.
- Portability: The source code is portable from one operating system to another. There is a version of PureBasic for Linux , Windows , AmigaOS , and Mac OS .
- No software dependencies : Language and applications do not require compulsory installation, so it is easy to transport it on a USB key, and run applications in portable applications .
- Creating DLL files : Creating standard DLLs (Non-ActiveX, usable in any other language) is as easy as creating EXE.
- The price: upgrades are free for life.
PureBasic has an extensive set of commands (over 1,400 internal commands ) plus simplified access to much of the operating system API . The programmer can call the commands of the API of Windows, Linux or Mac OS directly as if they were internal commands PureBasic, without declaring them first (and constant). Nothing better than a practical example to illustrate this. Let’s compare a simple program in Visual Basic with its equivalent in PureBasic: how to get the path to the Windows directory .
- Visual Basic:
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _ (ByVal lpBuffer As String, ByVal nSize As Long) As Long Const MAX_PATH = 260 StrWindowsDirectory $ = Space $ (MAX_PATH) LngReturn & = GetWindowsDirectory (strWindowsDirectory $, MAX_PATH)
StrWindowsDirectory $ = Space (#MAX_PATH) LngReturn = GetWindowsDirectory_ (strWindowsDirectory $, #MAX_PATH)
PureBasic manages many types:
- Ascii (.a)
- Byte (.b)
- Char (.c)
- Double (.d)
- Float (.f)
- Integer (.i)
- Long (.l)
- Quad (.q)
- String (.s)
- Unicode (.u)
- Word (.w)
- User-defined structures
PureBasic supports many features:
- Support for Unicode
- Thread-Safe Support
- 64-bit support (Windows, Linux, Mac OS)
- Support for different processors (x86, x64, PowerPC)
- 3DNOW / MMX / SSE / SSE2
- Inline assembler support (FASM (Windows and Linux) and NASM (MacOS) assembler)
- Support for different APIs
- Windows: Win32
- Linux: GTK +, OpenGL, SDL, LibC
- MacOS: Carbon, Cocoa
- All: LibXML
- Specific to Windows
- Themes support for Windows XP
- Support for Windows Vista UAC
PureBasic allows you to create:
- Executable (.exe) type GUI or Console
- DLLs (.dll)
- UserLibraries via an external tool: Tailbite or Moebius
- Import Libraries (.lib) via an external tool
- Executable GUI or Console
- Shared Libraries (.so)
- Executable GUI or Console
- Shared Libraries ( .dylib )
For information, here is the official list of PureBasic libraries:
- General Libraries
- 2D Drawing, CDAudio, Cipher, Clipboard, Console, Database, Sqlite and PostgreSQL, Date, Desktop, DragDrop, File, FileSystem, Gadget , Misc, Movie, Network, OnError, Packer, Preference, Process, Printer, Requester, Scintilla, Sort, StatusBar, String, SysTray, Thread, Toolbar, VectorDrawing
- Libraries for 2D games
- Joystick, Keyboard, Module, Mouse, Palette, Sprite & Screen, Sprite3D, Sound, SoundPlugin
- Libraries for 3D games
- Graphics, Graphics, Graphics, Graphics, Graphics, Graphics, Gadget3D,
- Sound3D, Special Effect, Spline, Static Geometry, Terrain, Texture, Vertex Animation, Window3D
You can of course create your own libraries in C language or in assembler, or directly in PureBasic thanks to a utility (“Tailbite”) developed by a user of PureBasic 1 .
This simple line of PureBasic code will create a tiny standalone executable of 4.50 KB ( 4,608 bytes ) for Windows.
MessageRequester ("", "Hello World")
And what follows is a short but perfect example of a functional program with PureBasic. The sum of the numbers entered by the user is displayed automatically. This program shows how to create a window, additional gadgets, as well as event management and a simple mathematical calculation. This code compiles into a 14.5 KB (14,848 bytes) standalone executable that can be used on any Windows 95-based PC running Windows 2003, Windows XP, Vista or Windows 7.
OpenWindow(1, 300, 300, 100, 100, "Title") StringGadget(1, 10, 10, 50, 20, "") StringGadget(2, 10, 40, 50, 20, "") TextGadget(3, 80, 30, 50, 20, "") Repeat Event = WaitWindowEvent() If Event = #PB_Event_Gadget FirstValue = Val(GetGadgetText(1)) SecondValue = Val(GetGadgetText(2)) SetGadgetText(3, Str(FirstValue + SecondValue)) EndIf Until ev = #PB_Event_CloseWindow
Moebius is an open source tool created by Progi1984 which allows to create from Purebasic code a userlib, on Windows and Linux 2 .
Tailbite is a tool created by ElChoni which allows to create from Purebasic code a userlib, only under Windows 1 .
The PureBasic visual editor ( Form Designer ) was created for the PureBasic programming language and is of course developed in PureBasic.
MADLib is a library (UserLib) of functions, for PureBasic. It was compiled by the utility Tailbite, developed by MAD 3 .
- ↑ a and b http://inicia.es/de/elchoni/TailBite/ [ archive ]
- ↑ https://github.com/Progi1984/Moebius [ archive ]
- ↑ http://sourceforge.net/projects/madlibforpb/ [ archive ]