Introduction

Welcome to Programming for the Absolute Beginner. This book is designed to provide a gentle and fun introduction to computer programming. For many, the mere thought of attempting to learn how to become a computer programmer is enough to make them turn and head for the hills. However, as you will see, learning how to program really is not that hard provided you have good instruction and a little patience.

You do not have to be a computer genius to learn how to program. While most people have only a very limited understanding of the internal mechanics of a car or motorcycle, they do not let that stop them from getting behind the wheel and learning to drive. Nor do you have to know how to build a computer from scratch or possess detailed understanding of the inner workings of your computer’s motherboard, hard drive, or any other hardware component in order to be able to operate a computer. The same is true of computer programming.

This book has been specifically written to assist you in learning how to become a programmer. It will provide you with enough background information to make sure that you know what is going on without inundating you with an overwhelming amount of technical jargon. While you will not be a programming guru by the end of this book, you will have learned the fundamentals of computer programming and will have the knowledge required to determine which of the many possible paths you want to pursue with your new programming skills.

What This Book Is All About

There are many programming languages available today, each with its own particular set of strengths and weaknesses. These programming languages run on different operating systems and can be very different from one another. Yet, despite these differences, all programming languages operate using the same basic set of rules. The purpose of this book is to teach you the basic rules that govern all programming languages and to explain the steps involved in designing, creating, and running a computer application.

Rather than attempt to provide detailed instruction for a number of different programming languages, I have chosen to focus on one specific language, BASIC. BASIC was originally created as a language for the purpose of teaching computer programming. As such, I have decided to adopt it as the programming language that this book will use to teach you how to program. Specifically, I have decided to use a version of BASIC called Just BASIC. Just BASIC does not cost anything and can be downloaded from the Internet. Just BASIC provides a simple streamlined version of BASIC that is easier for first-time programmers to learn than other BASIC programming languages, such as Microsoft Visual Basic, which is a highly complex version of BASIC that is used throughout the world to develop commercial software.

If you are looking for a good introduction to computer programming and are not sure yet which programming language you ultimately want to work with, this book will serve you well and will provide you with the skill and knowledge that you need to ultimately make that decision. If you are interested in learning an advanced programming language like Visual Basic .NET, Java, or C++, you will be well served by first learning the basic principles of BASIC programming prior to moving on and tackling these more complex languages.

Who Should Read This Book?

This book is designed to teach you how to become a programmer. By the time you are done with this book, you will not be a programming expert but you will have a solid understanding of how programming works. You will also have a good understanding of the strengths and weaknesses of different programming languages.

This book teaches you basic programming skills using a free implementation of the BASIC programming language called Just BASIC. It provides an excellent model through which you can learn the basics of computer programming, and it will help you to build a technical foundation from which you can later make the jump to other programming languages, should that be your goal.

Although previous programming experience is helpful, I wrote this book based on the assumption that you do not have any previous programming experience with BASIC or any other programming language. However, a good understanding of how to work with Microsoft Windows is required.

This book has been specifically designed to help jumpstart your programming career. By the time you have finished the book, you will have laid down a strong programming foundation that you can apply to other programming languages. This will help prepare you to learn more advanced BASIC programming languages such as Visual Basic and REALbasic or non-BASIC programming languages such as C#, C++, Java, JavaScript, Python, Perl, and so on.

Regardless of which programming language you eventually decide to learn and master, the purpose of this book is to provide you with a programming foundation that you build on and use as a starting point to achieve your goals. I believe that you will find this book very helpful as you begin your programming career and that you will be pleased with what the book has in store for you. I think this book’s unique game-based teaching approach will make your learning experience not only easier but also a lot more fun.

What You Need to Begin

This book was written using Just BASIC on a computer running Windows XP. Therefore, all of the figures and examples you will see show Just BASIC applications running on Windows XP. If you are running a different Windows operating system, you may notice small differences in the way your applications look. However, these differences will be purely cosmetic and you should not have any trouble following along with the examples presented in this book.

As of the writing of this book, the current version of Just BASIC is 1.01. You can download a free copy of Just BASIC at the Just BASIC website located at http://www.justbasic.com. The download is only 2.41 MB, so it will not take long to download and install. You can install and run Just BASIC on any of the following operating systems.

  • Windows 95

  • Windows 98

  • Windows Me

  • Windows NT

  • Windows 2000

  • Windows XP

  • Windows Vista

Compared to most programming languages and applications, Just BASIC has very modest hardware requirements, as shown in Table 1. These modest requirements combined with Just BASIC’s broad support for different Windows operating systems give you the ability to create Just BASIC applications for any Windows operating system, including older operating systems that many other programming languages no longer support. Of course, the minimum requirements shown in Table 1 are just that. For best performance, you will want to install Just BASIC and create Windows applications on a computer that meets the table’s recommended requirements.

Table 1. Minimum Requirements for Running Just BASIC

Requirement

Minimum

Recommended

Processor

486 or Pentium

Pentium

Memory

24 MB

64 MB

Hard Disk

6 MB

12 MB

That’s it. As long as you are running a supported version of Microsoft Windows and can download a free copy of Just BASIC, you will have everything that you need to take full advantage of the information and material covered in this book. Everything that you need to create Just BASIC applications is provided as part of the programming language.

How This Book Is Organized

Programming for the Absolute Beginner is organized into four major parts. I have written this book based on the assumption that it will be read sequentially, from cover to cover. If you are a first-time programmer, this is the approach that you will want to take. However, if you already have prior programming experience, then you may want to skip around a bit, selecting those topics that are of most interest to you.

The first part of this book consists of three chapters that provide you with background information that you need to know in order to get started. You will also learn the basic steps in creating BASIC applications using Just BASIC, and you will learn the steps involved in the formulation of graphical user interfaces made up of windows, buttons, and all sorts of other graphical controls.

The second part of this book is made up of four chapters from which you will learn a number of programming principles and techniques. The topics covered include learning how to store and retrieve data and how to write programs that react differently based on the data input they receive using conditional logic. You will learn how to create and use loops to perform repetitive actions and to process large amounts of data. You will also learn how to improve the overall organization of your BASIC applications using functions and subroutines.

The third part of this book is made up of three chapters that cover a number of advanced topics. These topics include learning how to work with text files and how to integrate sound and graphics into your BASIC applications. You will also learn the basic steps involved in tracking down and fixing program bugs that inevitably occur as part of the application development process.

The fourth part of this book is made up of two appendices and a glossary. The appendices outline the additional content that you will find on the book’s companion website and provide you with additional information and guidance that is designed to help you further your programming knowledge and skills.

The basic outline of the book is as follows.

  • Chapter 1, “Introduction to Programming.”This chapter provides you with a high-level overview of BASIC as well as background information that you will need to know in order to become an effective programmer. This will include a little historical background information as well as a comparison of BASIC to other programming languages. You also learn how to create your first BASIC application, the Knock Knock Joke game.

  • Chapter 2, “Creating Programs with Just BASIC.”In this chapter you will learn how to work with the Just BASIC editor. You will learn how to navigate the editor’s menus and toolbars. You will learn how to work with all of Just BASIC’s major features and to customize its settings to suit your personal preferences. You will also learn how to create stand-alone BASIC applications that can be run without requiring Just BASIC to be installed on the computer.

  • Chapter 3, “Creating Graphical User Interfaces.”This chapter will teach you the basic steps involved in designing and creating graphical user interfaces. You will learn how to create application windows and to populate them with all sorts of controls. You will also learn how to create application menus. In addition, you will learn how to configure the appearance of these controls and how to set them up to execute selected portions of your application code.

  • Chapter 4, “Working with Variables and Arrays.”This chapter will explain how programming languages store and retrieve data. Specifically, you will learn how to define data that never changes as well as how to store individual pieces or groups of related data whose values may change throughout the execution of your applications. You will also learn how to work mathematical and comparison operations and to perform basic text string manipulation.

  • Chapter 5, “Making Decisions with Conditional Logic.”This chapter will teach you how to develop programming logic that can analyze different values and alter its execution based on the results of that analysis. Using this information you will be able to create applications that can modify their execution based on the data that they are presented with.

  • Chapter 6, “Using Loops to Process Data.”In this chapter you will learn how to develop applications that are designed to repetitively perform a sequence of actions under the control of loops. You will also learn how to use loops to process large collections of data and to control the overall execution of BASIC applications and games.

  • Chapter 7, “Improving Program Organization with Functions and Subroutines.”This chapter will teach you how to make your applications easier to understand and maintain by showing you how to organize program code into procedures in the form of subroutines and procedures. You will learn how to pass data into procedures and to return it from procedures.

  • Chapter 8, “Working with Text Files.”In this chapter you will learn how to create applications that interact with the Windows file system. You will also learn how to create, open, and close text files as well as how to write data to and read data from them. You will also learn how to define and access simple database files.

  • Chapter 9, “Working with Sound and Graphics.”In this chapter you will learn how to integrate sound and graphics into your BASIC applications. This will include learning how to display animated graphic sequences and make sounds and play audio files.

  • Chapter 10, “Debugging Your Applications.”In this chapter you will learn how to find and fix program bugs that prevent your applications from running or cause your applications to run inappropriately. You will learn how to locate and fix syntax and logical errors. You will also learn how to use Just BASIC’s built-in debugger to locate and fix runtime errors. This will include learning how to trace program execution and set up breakpoints that pause application execution in order to allow you to check on the status of variable values.

  • Appendix A, “What’s on the Companion Website?”In this appendix I will provide you with an outline of the BASIC source code that you will find on this book’s companion website.

  • Appendix B, “What Next?”In this appendix, I will provide you with some final thoughts that are designed to help you continue your programming education. The information provided in this appendix will include links to websites where you can go to learn more about Just BASIC and other BASIC programming languages. I will also present you with a list of recommended reading that you may find helpful.

  • Glossary. This unit provides you with a glossary of key terms that are used throughout the book.

Conventions Used in This Book

To help make the book easier to understand and read, I have incorporated a number of special conventions to help make key points stand out so that they are easy to identify and understand. These conventions are as follows.

Hint

Hint

As you read along, I will suggest different or better ways of doing things to help make you a better and more efficient programmer.

Trap

Trap

I will identify places where mistakes are sometimes made and provide you with advice to help you avoid them.

Trick

Trick

Whenever possible, I will provide you with shortcuts and other techniques to help you make your work easier.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.14.200