PureBasic

PureBasic
ParadigmStructured, imperative, procedural
FamilyBASIC
Designed byFantaisie Software
DeveloperFantaisie Software
First appeared1998 (1998)
Stable release
6.11 LTS / June 5, 2024; 5 months ago (2024-06-05)
OSWindows, Linux, macOS, Raspberry Pi OS, AmigaOS
LicenseTrialware
Filename extensions.pb, .pbi, .pbf, .pbp
Websitewww.purebasic.com
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.

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.

 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

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

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.

Type Suffix Memory usage Numerical range
Byte b 1 byte (8 bits) −128 ... +127
Ascii a 1 byte (8 bits) 0 ... +255
Character c 1 byte (8 bits) (ascii) 0 ... +255
Word w 2 bytes (16 bits) −32768 ... +32767
Unicode u 2 bytes (16 bits) 0 ... +65535
Character c 2 bytes (16 bits) (unicode) 0 ... +65535
Long l 4 bytes (32 bits) −2147483648 ... +2147483647
Integer i 4 bytes (32 bits) x86 −2147483648 ... +2147483647
Float f 4 bytes (32 bits) Depending on the ratio of the decimal number.
Integer i 8 bytes (64 bits) x64 −9223372036854775808 ... +9223372036854775807
Quad q 8 bytes (64 bits) −9223372036854775808 ... +9223372036854775807
Double d 8 bytes (64 bits) Depending on the ratio of the decimal number.
String s (String length + 1) * SizeOf(Character) No limit.
Fixed String s{length} (String length) * SizeOf(Character) No limit.
  • Len(String) used to count the length of a string will not exceed the first null 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 the Dim var_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

  • 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

  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

Read other articles:

États membres du Code de conduite de La Haye Le Code de conduite international contre la prolifération des missiles balistiques, aussi connu sous le nom de Code de conduite de La Haye (HCoC), a été adopté le 25 novembre 2002 à La Haye par 101 pays. Son objet est de contribuer à réduire la prolifération de vecteurs balistiques pouvant emporter des armes de destruction massive. Contexte Le HCoC s'inscrit dans le prolongement des avancées importantes enregistrées durant les années 19...

 

Альберт Батиргазієв Загальна інформаціяПовне ім'я (рос. Альберт Ханбулатович Батыргазиев)Громадянство  РосіяНародився 23 червня 1998(1998-06-23) (25 років)Бабаюрт, Дагестан, РосіяAlma mater Nizhnevartovsk State Universityd[1]Вагова категорія Напівлегка (англ. Featherweight) (до 57,0 кг)Нагороди Орден Др

 

Mahārājdhirāja Nepal Bekas Kerajaan Lambang Royal (sebelum 2006) Gyanendra Bir Bikram Shah Penguasa pertama Mahārājdhirāja Prithvi Narayan Shah Penguasa terakhir Mahārājdhirāja Gyanendra Bir Bikram Shah Gelar His Royal Majesty Kediaman resmi Istana Kerajaan Narayanhity, Kathmandu, Nepal Penunjuk Turun-temurun Pendirian 25 September 1768 Pembubaran 28 Mei 2008 Penuntut takhta Mahārājdhirāja Gyanendra Bir Bikram Shah Raja Nepal secara tradisional digelari Mahārājdhirāja (श्र

ويكيبيديا الإندونيسيةلقطة شاشةمعلومات عامةموقع الويب id.wikipedia.org (الإندونيسية) تجاري؟ لانوع الموقع موسوعة حرةالتأسيس 30 مايو 2003 الجوانب التقنيةاللغة اللغة الإندونيسيةترخيص المحتوى رخصة المشاع الإبداعي الملزِمة بالنسب لمؤلِّف العمل وبالترخيص بالمثل غير القابلة للإلغاء 3.0

 

Ramón de Urrutia y Las Casas Corregidor de Oruro (1779 - 1781)-(1782 - 1784)Monarca Carlos III de EspañaPredecesor Joaquín Alós y Brú Gobernador Intendente de Tarma 1795-1809Monarca Carlos IV de EspañaPredecesor Francisco Suárez de CastillaSucesor José Gonzáles de Prada Información personalNacimiento 1742Zalla, Vizcaya, País Vasco, EspañaFallecimiento 1812Lima, PerúFamiliaCónyuge Águeda Arnao[editar datos en Wikidata] Ramón de Urrutia y Las Casas (Zalla, Vizcaya, Pa�...

 

Das Council on Tall buildings and Urban Habitat (deutsch: Rat für hohe Gebäude und städtischen Lebensraum; Abkürzung: CTBUH) ist ein Büro der Illinois Institute of Technology in Chicago, das sich mit der Bewertung der höchsten Gebäude (Skyscraper – Wolkenkratzer) der Welt befasst und Kriterien dafür aufstellt. Vorsitzender des 1969 von dem Ingenieur Lynn S. Beedle (1917–2003) gegründeten CTBUH ist Antony Wood. Danach werden inzwischen die Wolkenkratzer nach ihrer Höhe in drei Ka...

Gernikako Arbola (El árbol de Guernica), sebatang pohon ek. Gernika-Lumo (bahasa Spanyol: Guernica y Luno) adalah sebuah kotamadya di Negeri Basque, Spanyol bagian utara. Kota ini menjadi saksi bisu dalam Perang Saudara Spanyol, di mana pada tanggal 26 April 1937, kota ini dibom oleh Luftwaffe, yang mendukung Francisco Franco. Ribuan orang tewas dalam peristiwa tersebut. Peristiwa ini mengilhami Pablo Diego José Francisco de Paula Juan Nepomuceno María de los Remedios Cipriano de la Santí...

 

Academia de Bellas Artes de Florencia Tipo Universidad estatalFundación 1784LocalizaciónDirección Florencia, ItaliaCoordenadas 43°46′37″N 11°15′31″E / 43.776907, 11.258475Sitio web http://www.accademia.firenze.it/[editar datos en Wikidata] La Academia de Bellas Artes de Florencia (en italiano: Accademia di belle arti di Firenze) es una academia pública de arte, alojada en el antiguo Ospedale di San Matteo en la Via Ricasoli/Piazza San Marco de Florencia...

 

Intervensi Belanda di Bali (1846)Perang Bali IBatalyon VII maju dalam serangan ke BaliTanggal7 Mei 1848-1850LokasiBali, IndonesiaHasil Kemenangan Belanda yang menentukan. Belanda menguasai Bali Utara.Pihak terlibat Hindia Belanda Kerajaan Buleleng Kerajaan KarangasemTokoh dan pemimpin LaksDa.Engelbertus Batavus van den BoschKekuatan 23 kapal perang, 17 kapal, 1.280 serdadu, 115 senapan +10.000 prajurit lbsIntervensi Belanda di Bali Bali Utara (1846) Bali Utara (1848) Bali (1849) Bali (1858) L...

  关于与「王峰 (跳水运动员)」標題相近或相同的条目,請見「王峰」。 此生者传记没有列出任何参考或来源。 (2020年9月6日)请协助補充可靠来源,针对在世人物的无法查证的内容将被立即移除。 獎牌記錄 男子跳水 世界游泳錦標賽 2001年福岡 1米板 2003年巴塞隆納 双人3米板 2005年蒙特利爾 1米板 2005年蒙特利爾 双人3米板 2007年墨爾本 双人3米板 2009年羅馬 双人3米板 亞...

 

Android-based smartphone manufactured by OnePlus OnePlus 8TCodenamekebabBrandOnePlusManufacturerOnePlusSloganUltra Stops at NothingFirst released16 October 2020; 3 years ago (2020-10-16)Availability by region India:17 October 2020; 3 years ago (2020-10-17) Europe and China:20 October 2020; 3 years ago (2020-10-20) United States:23 October 2020; 3 years ago (2020-10-23) PredecessorOnePlus 8SuccessorOnePlus 9TypePhabletForm...

 

2011 game from Games Workshop This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Dreadfleet – news · newspapers · books · scholar · JSTOR (October 2011) (Learn how and when to remove this template message) DreadfleetManufacturersGames WorkshopDesignersPhil KellyPublishersGames Workshop ltd.Publication1 October ...

Book by Francis Sears University Physics 12th edition cover featuring the Millau Viaduct.AuthorHugh Young, Roger Freedman, Francis Sears, Mark ZemanskyCover artistYvo Riezebos DesignCountryUnited StatesLanguageEnglishGenrePhysicsPublisherPearson EducationPublication date1949Media typePrint (hardback & paperback)Pages1632 pp (14th edition, hardcover)[1]ISBN978-0-321-50062-5 University Physics, informally known as the Sears & Zemansky, is the name of a two-volume physi...

 

Leeds RiflesActiveFrom 1859Country United KingdomBranch Territorial ArmyRoleInfantry, armour, anti-aircraft artillerySize2 Territorial Battalions Up to 2 Second Line Territorial Battalions Up to 2 Reserve BattalionsGarrison/HQCarlton Barracks, LeedsAnniversariesBligny (28 July)Decorations Croix de Guerre Maple LeafCommandersNotablecommandersBrigadier Noel TetleyMilitary unit The Leeds Rifles was a unit of the 19th century Volunteer Force of the British Army that went on to serve under se...

 

2013–14 Air Force Falcons men's ice hockey seasonLedyard Bank Classic, Champion ConferenceT–3rd Atlantic HockeyHome iceCadet Ice ArenaRankingsUSCHO.comNRUSA TodayNRRecordOverall21–14–4Conference15–9–3Home12–5–2Road7–8–2Neutral2–1–0Coaches and captainsHead coachFrank SerratoreAssistant coachesAndy BergJoe DoyleCaptain(s)Adam McKenzieRyan TImarAlternate captain(s)Dan WeissenhoferAir Force Falcons men's ice hockey seasons« 2012–13 2014–15 » The 2013–1...

For other places with the same name, see Kowalewice. Village in Łódź Voivodeship, PolandKowalewiceVillageKowalewiceCoordinates: 51°56′8″N 19°17′43″E / 51.93556°N 19.29528°E / 51.93556; 19.29528Country PolandVoivodeshipŁódźCountyZgierzGminaParzęczew Kowalewice [kɔvalɛˈvit͡sɛ] is a village in the administrative district of Gmina Parzęczew, within Zgierz County, Łódź Voivodeship, in central Poland.[1] It lies approximately 7 kilome...

 

The neutrality of this article is disputed. Relevant discussion may be found on the talk page. Please do not remove this message until conditions to do so are met. (August 2021) (Learn how and when to remove this template message) Sajama National ParkIUCN category II (national park)Nevado SajamaLocationBoliviaOruro DepartmentCoordinates18°05′0″S 68°55′0″W / 18.08333°S 68.91667°W / -18.08333; -68.91667Area1,002 km²Established1939Governing bodyServicio ...

 

2009 studio album by CoronatusFabula MagnaStudio album by CoronatusReleased18 December 2009StudioKlangschmiede Studio E, MellrichstadtGenreGothic metalLength50:28LabelMassacreCoronatus chronology Porta Obscura(2008) Fabula Magna(2009) Terra Incognita(2011) Fabula Magna is the third full-length studio album by German gothic metal band Coronatus. Thematically it focuses on myths, tales and legends.[1] Reception Professional ratingsReview scoresSourceRatingMetal.de6/10[2]...

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: The Colors in the Wheel – news · newspapers · books · scholar · JSTOR (September 2020) (Learn how and when to remove this template message) 2006 studio album by Venus HumThe Colors in the WheelStudio album by Venus HumReleasedJuly 24, 2006[1]Gen...

 

Erixx GmbHTypeGmbHFounded2011HeadquartersCelle, GermanyNumber of locations67 stationsArea servedHVV, GVH, VBN [de]Key peopleWolfgang KloppenburgServicesPassenger transportationParentOsthannoversche Eisenbahnen AG (OHE)Websitewww.erixx.de An Erixx train at Hannover Hauptbahnhof Erixx GmbH (stylized as erixx) is a private railway company operating regional train service in Lower Saxony and Bremen, northern Germany. It is wholly owned by Osthannoversche Eisenbahnen AG (OHE). Since 1...