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:

Universitas Mandalayမႏၲေလးတကၠသိုလ္JenisPublicRektorKhin Swe OoLokasiMahaaungmye Mandalay, MyanmarKoordinat: 21°57′30″N 96°5′30″E / 21.95833°N 96.09167°E / 21.95833; 96.09167AfiliasiAUNSitus webwww.mu.edu.mm Universitas Mandalay (Bahasa Myanmar: မန္တလေးတက္ကသိုလ် dibaca [màɴdəlé tɛʔkəθò]) merupakan sebuah universitas seni liberal publik berlokasi di Mandalay, Myanmar. Sebelumnya berafiliasi ...

 

 

Эта страница требует существенной переработки. Возможно, её необходимо правильно оформить, дополнить или переписать.Пояснение причин и обсуждение — на странице Википедия:К улучшению/2 сентября 2023. Эта статья является неполным списком войн и конфликтов с участием Австр�...

 

 

Kontributor utama artikel ini tampaknya memiliki hubungan dekat dengan subjek. Artikel ini mungkin memerlukan perapian untuk mematuhi kebijakan konten Wikipedia, terutama dalam hal sudut pandang netral. Silakan dibahas lebih lanjut di halaman pembicaraan artikel ini. (Pelajari cara dan kapan saatnya untuk menghapus pesan templat ini)SMA INS KayutanamRuang Pendidik SMA INS KayutanamInformasiDidirikan31 Oktober 1926JenisSekolah Menengah Atas SwastaAkreditasiANomor Pokok Sekolah Nasional10308098...

Koordinat: 52°31′30″N 13°22′09″E / 52.52493°N 13.369181°E / 52.52493; 13.369181 Stasiun Utama BerlinBerlin HauptbahnhofHbfFasad selatan stasiun Berlin HbfLokasiEuropaplatz 110557 BerlinMitte, Berlin JermanKoordinat52°31′30″N 13°22′10″E / 52.52500°N 13.36944°E / 52.52500; 13.36944Jalur Stadtbahn Jalur utama Utara–Selatan U-5 Jumlah peron8 (total)Jumlah jalur16 (total)Operator KADB FernverkehrDB Regio NordostFlixTrai...

 

 

خبز النانनान (بالهندية) معلومات عامةالمنشأ الهند — الصين بلد المطبخ مطبخ هندي النوع خبز مفرود المكونات الرئيسية طحين القمح زبادي تعديل - تعديل مصدري - تعديل ويكي بيانات خبز النان خبز النان (بالفارسية: نان، بالهندية: नान، بالبنجابية: ਨਾਨ ،بالصينية:馕)، وهو نوع من الخبز ا�...

 

 

Eritrean diaspora in Sweden Eritreans in SwedenTotal population45,734[1]Regions with significant populationsStockholm, Gothenburg, Malmö, SundsvallLanguagesTigrinya · Tigre · Kunama  · Nara  · Afar,  · Beja · Saho · Bilen · Arabic  · English  · SwedishReligionEritrean Orthodox Tewahedo Church, Islam Eritreans in Sweden are citizens and res...

This article needs to be updated. Please help update this article to reflect recent events or newly available information. (September 2010) Bradford City 2008–09 football seasonBradford City2008–09 seasonChairmanMark LawnJulian RhodesManagerStuart McCallFA CupSecond roundLeague CupFirst roundFootball League TrophyFirst roundTop goalscorerLeague: Peter Thorne (17)All: Peter Thorne (17)Highest home attendance14,038 vs Notts County (9 August 2008)Lowest home attendance5,065 vs Leyton Orient...

 

 

Indian politician Presidency of Ram Nath Kovind25 July 2017 – 25 July 2022PresidentRam Nath KovindPartyBharatiya Janata PartyElection2017 Indian presidential electionSeatRashtrapati Bhawan← Pranab MukherjeeDroupadi Murmu → Emblem of India The presidency of Ram Nath Kovind began on 25 July 2017, when he took the oath as the fourteenth president of India administered by Chief Justice Jagdish Singh Khehar. Kovind was the Bharatiya Janata Party (BJP)-led National ...

 

 

This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) 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: GNR Ivatt 1 Class 0-6-0 – news · newspapers · books · scholar · JSTOR (January 2022) (Learn how and when t...

Malay supremacist non-governmental organisation (NGO) Pertubuhan Pribumi Perkasaڤرتوبوهن ڤريبومي ڤرکاسMighty Native OrganisationPERKASAFormation2008TypeMalay supremacy, Malayisation, extreme-right, ultra-nationalism, Islamonationalism, Cultural chauvinismPurposeprotect Article 153 of the Constitution of Malaysia, defend the rights of Bumiputera from being eroded, defend the rights of the Malays which are allegedly being challenged by non-Malays in Malaysia.LocationMalaysia...

 

 

Not to be confused with Pauwels Sauzen–Bingoal. Belgian cycling team Bingoal WBTeam vehicles at the 2019 Volta Limburg ClassicTeam informationUCI codeBWBRegisteredBelgiumFounded2011 (2011)Discipline(s)RoadStatusUCI Continental (2011–2016) UCI Professional Continental/ProTeam (2017–present)BicyclesDe RosaTeam name history2011–20122013–20152016201720182019202020212021–20222023–Wallonie Bruxelles–Crédit AgricoleWallonie–BruxellesWallonie Bruxelles–Group ProtectWB Veranc...

 

 

Laurel Fork South WildernessIUCN category Ib (wilderness area)[1]Overlook of Laurel Fork valley along Middle Mountain Road on a foggy fall day.Location of Laurel Fork South Wilderness in West VirginiaLocationWest Virginia, United StatesCoordinates38°42′43″N 79°43′07″W / 38.71194°N 79.71861°W / 38.71194; -79.71861Area5,784 acres (23.41 km2)[2]Established1983[2]OperatorMonongahela National ForestWebsiteLaurel Fork Wildernesses Lau...

Decentralized subdivisions of the Republic of Colombia Municipalities of Colombia The municipalities of Colombia are decentralized subdivisions of the Republic of Colombia. Municipalities make up most of the departments of Colombia with 1,122 municipalities (municipios). Each one of them is led by a mayor (alcalde) elected by popular vote and represents the maximum executive government official at a municipality level under the mandate of the governor of their department which is a representa...

 

 

Prof. Amalia E. Maulana, Ph.D. Informasi pribadiKebangsaanIndonesiaPekerjaanAkademisi, Praktisi, Penulis, Dosen, Guru BesarSitus webhttp://amaliaemaulana.com/Sunting kotak info • L • B Prof. Amalia E. Maulana, Ph.D. adalah Guru Besar tetap bidang Marketing dari BINUS Business School, BINUS University, Jakarta, Indonesia[1]. Bergabung di institusi ini sejak tahun 2006[2]. Sebelum menjadi faculty member dan academic researcher, Amalia memiliki lebih dari 15 tahun p...

 

 

Cet article est une ébauche concernant une localité hongroise. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Tarnaszentmária Blason de Tarnaszentmária Tarnaszentmária Tarnaszentmária Administration Pays Hongrie Comitat (megye) Heves (Hongrie septentrionale) District (járás) Eger Rang Commune Bourgmestre(polgármester) Mandat Czipó István László (indépendant) (2014-2019) Code postal 3331 Indicatif ...

متحف آثار الإسماعيليةمعلومات عامةنوع المبنى متحف المنطقة الإدارية محافظة الإسماعيلية البلد  مصر معلومات أخرىالإحداثيات 30°35′35″N 32°17′01″E / 30.592987°N 32.283642°E / 30.592987; 32.283642 تعديل - تعديل مصدري - تعديل ويكي بيانات متحف آثار الإسماعيلية هو متحف بمدينة الإسماعيلية �...

 

 

American multinational technology company This article is about the company. For the search engine provided by the company, see Google Search. For the parent company with the stock tickers GOOG and GOOGL, see Alphabet Inc. For the number, see Googol. For other uses, see Google (disambiguation). Google LLCThe Google logo used since 2015Google's headquarters, the GoogleplexFormerlyGoogle Inc. (1998–2017)Company typeSubsidiaryTraded asNASDAQ: GOOGL, GOOGIndustryInternetCloud computingComputer ...

 

 

سرطان الرئة تصوير الصدر بالأشعة السينية يُظهر السهم الأحمر ورمًا في الرئة اليُسرىتصوير الصدر بالأشعة السينية يُظهر السهم الأحمر ورمًا في الرئة اليُسرى معلومات عامة الاختصاص علم الأورام،  وطب الرئة  من أنواع مرض رئوي  [لغات أخرى]‏،  ومرض  الأنواع سرطان ا�...

Irish republican and politician (1917–2006) Ruairí BrughaBrugha in 1977Member of the European ParliamentIn officeDecember 1977 – June 1979ConstituencyOireachtas DelegationSenatorIn office16 June 1977 – 8 October 1981In office5 November 1969 – 1 June 1973ConstituencyIndustrial and Commercial PanelTeachta DálaIn officeFebruary 1973 – June 1977ConstituencyDublin County South Personal detailsBorn(1917-10-15)15 October 1917Dublin, IrelandDied31 Janua...

 

 

Pour les articles homonymes, voir Alonso. Alonso Olano est un nom espagnol. Le premier nom de famille, paternel, est Alonso ; le second, maternel, souvent omis, est Olano. Xabi Alonso Xabi Alonso en 2018. Situation actuelle Équipe Bayer Leverkusen (entraîneur) Biographie Nom Xabier Alonso Olano Nationalité Espagnole Naissance 25 novembre 1981 (42 ans) Tolosa (Espagne) Taille 1,83 m (6′ 0″) Période pro. 2000 – 2017 Poste Milieu défensif Pied fort Droit Parcours ...