You are previewing Programming for the Absolute Beginner.
O'Reilly logo
Programming for the Absolute Beginner

Book Description

Want to learn computer programming but aren't sure where to start? Programming for the Absolute Beginner provides a gentle learning curve in programming for anyone who wants to develop fundamental programming skills and create computer programs. The primary focus is on teaching the reader how to program using a free implementation of BASIC called Just BASIC. As such, the book focuses on developing programs that run on Microsoft® Windows®, but also presents programming principles that apply to different environments, including other operating systems and the Internet. Additionally, the book provides a solid foundation for advancing to different programming languages as you gain confidence in your newly acquired programming abilities. As part of the for the absolute beginner series, Programming for the Absolute Beginner teaches all the concepts through the creation of simple computer games, making the learning process much more fun and enjoyable.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. About the Author
  4. Introduction
    1. What This Book Is All About
    2. Who Should Read This Book?
    3. What You Need to Begin
    4. How This Book Is Organized
    5. Conventions Used in This Book
  5. 1. Introduction to Programming
    1. Project Preview: The Knock Knock Joke Game
    2. Getting Started
    3. Programming Overview
    4. Deciding What Programming Language to Learn and Use
    5. Creating Your Own Solutions
    6. Mastering the Art of Program Logic
    7. Talking in a Language Computers Understand
      1. Machine Language
      2. Assembly Language
      3. Fortran and COBOL
      4. C
      5. C++ and Objective-C
      6. BASIC
      7. Java
    8. Other Types of Programming Languages
      1. Scripting Languages
      2. Embedded Application Languages
      3. Web Development Languages
      4. Database Languages
      5. Finding the Right Programming Language
    9. Getting Started with Just BASIC
      1. Installing Just BASIC
      2. Creating and Executing Your First BASIC Program
    10. Back to the Knock Knock Joke Game
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Displaying the Opening Prompt
        3. Analyzing Player Input
        4. Telling the Second Joke
        5. Telling the Last Joke
        6. Terminating the Program
      2. The Final Result
    11. Summary
  6. 2. Creating Programs with Just Basic
    1. Project Preview: The Legend of Mighty Molly
    2. Tools of the Trade
    3. Working with Just BASIC
      1. The World of Just BASIC Window
        1. Community
        2. Liberty BASIC
        3. Links
        4. Tutorial
        5. Resources
        6. News
      2. The Code Editor Window
        1. Just BASIC’s Menu System
        2. Just BASIC’s Toolbar
    4. Configuring Just BASIC Preferences
      1. Notification Settings
      2. Startup Settings
      3. Compiler Settings
      4. Environmental Settings
      5. Other Configuration Options
    5. Working with Applications
      1. Opening and Saving Programs
      2. Killing Programs
    6. Other Just BASIC Components
      1. Designing Forms
      2. The Just BASIC Debugger
    7. Building standalone Applications
      1. Creating a Tokenized File
      2. Distributing Your Just BASIC Applications
    8. Back to the Legend of Mighty Molly
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Displaying a Welcome Screen
        3. Providing Game Instructions
        4. Prompting the Player for Input
        5. Collecting Additional Player Input
        6. Beginning the Story
        7. Telling the Rest of the Story
        8. Preparing to End the Program
      2. The Final Result
    9. Summary
  7. 3. Creating Graphical User Interfaces
    1. Project Preview: The BASIC Crazy 8 Ball Game
    2. Mainwin
    3. GUI Application Development
    4. Working with Application Windows
      1. Regular Windows
      2. Text Windows
      3. Graphics Windows
      4. Dialog Windows
      5. Window Variations
      6. Opening and Closing Windows
      7. Event Programming
      8. Specifying Window Size and Location
      9. Setting Foreground and Background Colors
      10. Setting Font Attributes
    5. Adding Controls to Windows
      1. A Quick Review of Just BASIC Controls
        1. Button Controls
        2. Bmpbutton Controls
        3. Checkbox Controls
        4. Radiobutton Controls
        5. Statictext Controls
        6. Textbox Controls
        7. Texteditor Controls
        8. Listbox Controls
        9. Combobox Controls
        10. Groupbox Controls
        11. Graphicbox Controls
      2. Setting Control Focus
      3. Enabling and Disabling Controls
      4. Specifying Control Font and Color
    6. Building Application Menus
    7. Building Interfaces with FreeForm-J
      1. Designing an Application Window
      2. Using FreeForm-J to Build Window Menus
      3. Using FreeForm-J to Generate Source Code
    8. Taking Advantage of Built-in Dialogs
      1. Notice
      2. Confirm
      3. Prompt
      4. Filedialog
    9. Back to the BASIC Crazy 8 Ball Game
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Displaying a Welcome Screen
        3. Initiating Game Play
        4. Controlling Game Termination from the Welcome Screen
        5. Prompting the Player to Ask a Question
        6. Generating Answers
        7. Terminating Game Play
      2. The Final Result
    10. Summary
  8. 4. Working with Variables and Arrays
    1. Project Preview: The Ask Mustafa Game
    2. Working with Program Data
      1. Exploring Different Ways of Storing Data
        1. Defining Constants
        2. Declaring Variables
        3. Creating Arrays
        4. Other Data Storage Options
      2. Working with Different Types of Data
    3. Learning How to Work with Variables
      1. Declaring Variables
      2. Storing Data in Variables
      3. Understanding Scope
        1. Working with Local Variables
        2. Working with Global Variables
      4. Variable Naming Rules
      5. Converting Variables
        1. Converting from String to Numeric Values
        2. Converting from Numeric to String Values
      6. Working with Numeric Variables
      7. Functions that Manipulate Strings
    4. Storing Data in Arrays
      1. Creating an Array
      2. Retrieving Data from an Array
      3. Resizing an Array
    5. Reserved Words
    6. Back to the Ask Mustafa Game
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Welcoming the Player
        3. Starting Game Play
        4. Closing the Opening Window
        5. Accepting Player Input
        6. Answering Player Questions
        7. Providing the Player with a Hint
        8. Terminating Game Play
      2. The Final Result
    7. Summary
  9. 5. Making Decisions with Conditional Logic
    1. Project Preview: The Rock, Paper, Scissors Game
    2. Building Adaptive Applications With Conditional Logic
    3. Working with the if...then Statement
      1. Understanding if...then Syntax
      2. Creating Single Line if...then Statements
      3. Creating Multiple-Line if...then Statements
      4. Checking for Alternative Conditions
    4. Exploring the Power of Nesting if...then Statements
    5. Working with the select...Case Statement
    6. Performing Different Types of Comparison Operations
    7. Performing Mathematic Calculations
      1. Order of Precedence
      2. Overriding the Rules of Precedence
    8. Combining and Negating Comparison Operations
    9. Back to the Rock, Paper, Scissors Game
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Designing the Application’s User Interface
        3. Enabling the Go Button
        4. Managing Game Play
        5. Terminating Application Execution
      2. The Final Result
    10. Summary
  10. 6. Using Loops to Process Data
    1. Project Preview: The Guess My Number Game
    2. Using Loops to Repeat Statement Execution
      1. The do...while Loop
      2. The do...until Loop
      3. The for...next Loop
      4. The while...wend Loop
    3. Looking Out for Endless Loops
    4. Busting Out of Loops
    5. Back to the Guess My Number Game
      1. Designing the Game
        1. Creating a Just BASIC File
        2. Designing the Game’s User Interface
        3. Analyzing the Player’s Guesses
        4. Starting a New Game
        5. Creating a Help Window
        6. Closing the Help Window
        7. Terminating Application Execution
      2. The Final Result
    6. Summary
  11. 7. Improving Program Organization with Functions and Subroutines
    1. Project Preview: The BASIC BlackJack Game
    2. Working with Subroutines and Functions
      1. Defining Subroutines
      2. Using a Subroutine as an Event Handler
        1. Programmatically Calling a Subroutine
      3. Prematurely Terminating a Subroutine
      4. Defining Functions
        1. Executing Functions
        2. Prematurely Terminating a Function
    3. Different Ways to Pass Arguments to Procedures
      1. Passing Arguments by Value
      2. Passing Arguments by Reference
    4. Taking Advantage of Built-in Function Libraries
    5. Back to the BASIC BlackJack Game
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Initializing the Game
        3. Creating the DisplaySplash Subroutine
        4. Creating the CloseSplashWindow Subroutine
        5. Creating the ManageGamePlay Subroutine
        6. Creating the DealCard Subroutine
        7. Creating the DealerTurn Subroutine
        8. Creating the RestartGame Subroutine
      2. Creating the DealOpeningHand Subroutine
        1. Creating the GetRandomNumber Function
        2. Creating the ResetGame Subroutine
        3. Creating the ClosePlay Subroutine
      3. The Final Result
    6. Summary
  12. 8. Working with Text Files
    1. Project Preview: The Tic Tac Toe Game
    2. Working with Files and Folders
      1. Retrieving Drive Information
      2. Retrieving Information about the Current Working Directory
      3. Collecting Data about Files and Folders
      4. Ensuring that Files Exist
      5. Specifying Absolute File and Path Names
      6. Specifying Relative Path Names
      7. Using the filedialog Window to Allow the User to Select a File
    3. Working with Files
      1. Opening Files
      2. Closing Files
      3. Reading from Files
      4. Writing to Files
        1. Creating and Writing to New Files
        2. Appending Text to the End of an Existing File
    4. File and Folder Administration
      1. Renaming Files
      2. Deleting Files
      3. Creating New Folders
      4. Deleting Folders
    5. Back to the Tic Tac Toe Game
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Defining Global Variables and Initiating Game Play
        3. Displaying the Game Board
        4. Processing Player Moves
        5. Controlling Player Turns
        6. Looking for the End of the Game
        7. Preparing for a New Game
        8. Terminating Game Play
      2. The Final Result
    6. Summary
  13. 9. Working with Sound and Graphics
    1. Project Preview: The Slot Machine Game
    2. Integrating Graphics and Sound into Applications
    3. Displaying Graphic Images
    4. Understanding How Just BASIC Manages Drawings
    5. Just BASIC’s Graphics Capabilities
    6. Drawing Graphics
      1. A Quick Review of Graphic Commands
      2. Working with the Graphics Window
      3. Working with the Graphicbox Control
      4. Using Different Colors
      5. Clearing Out a Drawing
      6. Setting Up Mouse and Keyboard Event Handlers
    7. Creating a Drawing Application
    8. Getting Your Applications to Make Some Noise
      1. Making Noise
      2. Playing Wave Files
      3. Playing MIDI Files
    9. Back to the Slot Machine Game
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Initializing Game Play
        3. Designing the Game’s User Interface
        4. Controlling Game Automation
        5. Animating the Slot Machine’s Spin
        6. Displaying Slot Machine Graphics
        7. Selecting the Slot Machine’s Ultimate Result
        8. Terminating Game Play
      2. The Final Result
    10. Summary
  14. 10. Debugging Your Applications
    1. Project Preview: The Hangman Game
    2. Coping With Errors in Your Applications
      1. Understanding Syntax Errors
      2. Coping with Logical Errors
      3. Eliminating Runtime Errors
    3. What Is Just BASIC’s Error.Log File?
    4. Debugging Your Just BASIC Applications
      1. Working with the Debugger Toolbar
      2. Examining Variable Values
      3. A Quick Demonstration of How to Use the Debugger
    5. Developing a Runtime Error Handler
    6. Back to the Hangman Game
      1. Designing the Game
        1. Creating a Just BASIC File Script
        2. Defining Global Variables and an Array
        3. Designing the Game’s User Interface
        4. Starting a New Game
        5. Retrieving a Mystery Word
        6. Processing Player Guesses
        7. Validating Player Guesses
        8. Preparing for a New Game
        9. Getting Player Confirmation Before Closing the Game
      2. The Final Result
    7. Summary
  15. A. What’s on the Companion Website?
  16. B. What Next?
    1. Locating Just BASIC Resources Online
      1. The Just BASIC Forum
      2. The Just BASIC wiki Site
      3. The Just BASIC Newsletter
      4. The Just BASIC Files Archive
      5. The Just BASIC and Liberty BASIC Forum
    2. Liberty BASIC
      1. Liberty BASIC Workshop
      2. Liberty BASIC ToolBox
    3. Other BASIC Programming Languages
      1. REALbasic
      2. Visual Basic
      3. NS Basic
      4. Other BASIC Programming Languages
      5. Non-BASIC Programming Languages
    4. Scripting Languages
      1. Visual Basic for Applications
      2. VBScript
    5. Recommended Reading
    6. www.tech-publishing.com
  17. Glossary