Example: stock market

PureBasic - A Beginner's Guide To Computer Programming

PurebasicA beginner s Guide To Computer ProgrammingUpdated forPurebasic v4 Gary WilloughbyPurebasicGary WilloughbyA Beginners Guide To Computer ProgrammingPureBasic - A beginner s Guide To Computer Programmingby Gary WilloughbyCopyright 2006 Gary WilloughbyThis book and all included source materials such as diagrams, photos and PureBasic source code isdistributed under the Creative Commons Attribution Non-Commercial Share Alike License. Moredetails can be found here: is a registered trademark of Fantaisie Software. PureBasic and all provided tools andcomponents contained within the PureBasic package are Copyright 2006 Fantaisie Software10, rue de Lausanne67640 2006, by Aardvark Global WilloughbyPrint HistoryJuly 2006 - First EditionDisclaimerWhile every precaution has been taken in the preparation of this book and the programs containedwithin it, the author and publisher assumes no responsibility whatsoever for errors, omissions, or fordamages resulting from the use of the information or programs contained herein.

PureBasic raises the bar to not only what a Basic language should be but also what all languages should be. Clean, uncluttered syntax, small compiled executable files and a fantastically active community of programmers. Hopefully this book will give you a clear understanding of the core features of PureBasic

Tags:

  Guide, Basics, Beginner, Purebasic, Purebasic a beginner s guide

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of PureBasic - A Beginner's Guide To Computer Programming

1 PurebasicA beginner s Guide To Computer ProgrammingUpdated forPurebasic v4 Gary WilloughbyPurebasicGary WilloughbyA Beginners Guide To Computer ProgrammingPureBasic - A beginner s Guide To Computer Programmingby Gary WilloughbyCopyright 2006 Gary WilloughbyThis book and all included source materials such as diagrams, photos and PureBasic source code isdistributed under the Creative Commons Attribution Non-Commercial Share Alike License. Moredetails can be found here: is a registered trademark of Fantaisie Software. PureBasic and all provided tools andcomponents contained within the PureBasic package are Copyright 2006 Fantaisie Software10, rue de Lausanne67640 2006, by Aardvark Global WilloughbyPrint HistoryJuly 2006 - First EditionDisclaimerWhile every precaution has been taken in the preparation of this book and the programs containedwithin it, the author and publisher assumes no responsibility whatsoever for errors, omissions, or fordamages resulting from the use of the information or programs contained herein.

2 The author orpublisher shall not be liable if incidental or consequential damages occur in connection with, or arisingfrom, the furnishings, performance, or use of the programs, associated instructions, and/or claims ofproductivity gains. All information contained herein is considered accurate at time of publication butbecause PureBasic is a language in a constant state of refinement and development, some informationover time may be rendered out-of-date. For up to date news and information regarding PureBasicplease refer to names appear throughout this book. Rather than list the names and entities that ownthe trademarks or insert a trademark symbol with each mention of the trademarked name, thepublisher states that it is using the names for editorial purposes only and to the benefit of thetrademark owner, with no intention of infringing on that to my girlfriend, Sara Jane Gostick and her dog Stella for putting up with many lonelynights while I wrote this book and for the encouragement (and chicken dinners) she always to Fred and the PureBasic team for the PureBasic language, keep up the good work, it rocks!

3 Thanks to Paul Dixon for clarifying some of the details regarding binary encoding of floating to Timo Harter for helping to choose what PureBasic data types would best substitute theWin32 API types, and for demonstrating how to retrieve different strings from memory via thedifferent Win32 API String pointer types. With great power there must also come great responsibility! --Ben Parker (Spiderman s Uncle)Code examples contained in this book can be downloaded freely 1-4276-0428-2 19/7/2006vTable of ContentsPreface .. Core Language ..11. Getting Started ..3 The History Of PureBasic ..3 The Development Philosophy Of PureBasic ..5A First Look At The IDE ..6 How To Run PureBasic Programs ..7 The Debugger ..8A Note On Program Structure ..8 Introducing The PureBasic Help File ..92. Data Types ..10 Built-In Data Types ..10 Numbers ..10 Strings ..12 Variables And Constants.

4 123. Operators ..18 An Introduction To Operators ..18 Operator Precedence ..33 Expression Notes ..344. Conditional Statements And Loops ..37 Boolean Logic ..37 The If Statement ..38 The Select Statement ..41 Loops ..435. Other Data Structures ..49 Structures ..49 Arrays ..52 Linked Lists ..62 Sorting Arrays And Linked Lists ..676. Procedures And Subroutines ..71 Why Use Procedures Or Subroutines? ..71 Subroutines ..71 Procedure basics ..74 Program Scope ..76 The Global Keyword ..78 The Protected Keyword ..79 The Shared Keyword ..80 Table of ContentsviThe Static Keyword ..82 Passing Variables To Procedures ..83 Passing Arrays To Procedures ..86 Passing Linked Lists To Procedures ..88 Returning A Value From Procedures ..917. Using Built-In Commands ..93 Using The PureBasic Helpfile ..93PB Numbers And OS Identifiers ..95 Examples Of Common Commands.

5 98 Handling Files ..104 Read The Helpfile ..1108. Good Programming Style ..111 Why Bother Formatting Code ..111 The Value Of Comments ..112My Coding Format ..113 Golden Rules For Writing Easily Readable Code ..116 How To Minimize And Handle Errors ..117II Graphical User Interfaces ..1299. Creating User Interfaces ..131 Console Programs ..131 Creating Native User Interfaces ..137 Understanding Events ..139 Adding Gadgets ..140 Adding A Menu ..148 Menu Keyboard Shortcuts ..153 Including Graphics In Your Program ..156A First Look At The New Visual Designer ..162 III Graphics And Sound ..16510. 2D Graphics ..1672D Drawing Commands ..167 Saving Images ..179 Introducing Screens ..181 Sprites ..19211. 3D Graphics ..203An Overview Of The OGRE Engine ..203A Gentle Beginning ..206A Simple First Person Camera ..215A Little More Advanced ..221 What s Next?

6 226 Table of Contentsvii12. Sound ..227 Wave Files ..227 Module Files ..231Mp3 s ..233CD Audio ..237IV Advanced Topics ..24313. Beyond The basics ..245 Compiler Directives And Functions ..245 Advanced Compiler Options ..252 Parsing Command Line Parameters ..259A Closer Look At Numeric Data Types ..262 Pointers ..269 Threads ..279 Dynamic Link Libraries ..287 The Windows Application Programming Interface ..293 VAppendices ..303A. Useful Internet Links ..305B. Helpful Charts ..307C. Glossary ..317 Index ..332 PrefaceAbout this BookThis book provides a quick introduction to the PureBasic Programming language. PureBasic spopularity has increased significantly in the past few years, being used for many purposes such asrapid software prototyping, creation of commercial applications and games, Internet CGI applications,while some people just use it for small utilities.

7 This book has been written, with the complete novicein mind. We all need to start somewhere and I believe PureBasic is a fantastic first leap into theprogramming world. With PureBasic becoming more and more widely used, many people are startingout and finding they need the occasional push in the right direction or need an explanation of a certainfeature or oddity. This book is to Guide novices through their first steps and to give the seasonedprogrammer a quick overview of the Book s ScopeAlthough this book covers the essentials of the PureBasic language, I ve kept this book s scope quitenarrow to make sure it s not information overload for new users. Sometimes this text will refer toconcepts and syntax in a simplistic way to be used as a stepping stone to more advanced texts or as acomplement to the existing PureBasic example I won t talk much about how easy it is to use DirectX or OpenGL directly in PureBasic ,otherwise this book would be triple in size and although topics such as pointers, threads and theWin32 API is talked about later in this book, don t expect too many fancy examples as I ve only givenan overview to such advanced raises the bar to not only what a Basic language should be but also what all languages shouldbe.

8 Clean, uncluttered syntax, small compiled executable files and a fantastically active community ofprogrammers. Hopefully this book will give you a clear understanding of the core features of PureBasicand the design goals and philosophies behind its creation and hopefully make you want to learn this books limited scope, I think you will find this a great first book on PureBasic which willalso give you a solid grounding on Programming in general if you were to migrate to other will learn everything you need to start writing useful standalone programs. By the time you vefinished this book, you will have learned not only the essentials of the language itself, but also how toapply that knowledge to day-to-day tasks. You will also be better equipped to tackle more advancedtopics as they come your Book s StructureMuch of this book is designed to introduce you to PureBasic as quickly as possible and is organized bypresenting the major language features a section at a time.

9 Each chapter is fairly self contained butlater chapters, especially the more advanced ones, use ideas introduced earlier. For example, when weget to graphical user interfaces and graphics, I ll assume you now understand procedures I: The Core LanguageThis part of the book is a straightforward bottom-up explanation of the major language features, suchas types, procedures, structures and so on. Most of the examples given are not really very useful asstandalone programs but are there to demonstrate and explain the current 1, Getting StartedHe we start with a quick introduction to PureBasic and the history behind the language. An overviewon how to run a PureBasic program from the IDE and what the debugger is 2, Data TypesIn this chapter I start by listing and explaining all the available built-in data types, such as Strings,number types and constants.

10 Usage guidelines are given for all the built-in data types as well asinformation on memory usage and where applicable, numerical 3, OperatorsHere I explain the basic means to actually assign values to variables and explain what operators areneeded for calculating data. A full explanation is given for all operators along with diagrams andexamples. The Debug command is also introduced here as it is one of the most useful commands inthe PureBasic language and its importance should be learned early 4, Conditional Statements And LoopsIn this chapter I explain how PureBasic handles boolean values, the If and Select statements areintroduced and loops are explained and demonstrated. Examples and full explanations are 5, Other Data StructuresThis chapter reveals how to create and use other methods for storing and organizing data, such as userdefined structures, arrays and linked lists.


Related search queries