- •About the Author
- •Dedication
- •Author’s Acknowledgments
- •Contents at a Glance
- •Table of Contents
- •Introduction
- •Who Should Buy This Book
- •How This Book Is Organized
- •Part I: Programming a Computer
- •Part II: Learning Programming with Liberty BASIC
- •Part III: Advanced Programming with Liberty BASIC
- •Part VI: Internet Programming
- •Part VII: The Part of Tens
- •How to Use This Book
- •Foolish assumptions
- •Icons used in this book
- •Why Learn Computer Programming?
- •How Does a Computer Program Work?
- •What Do I Need to Know to Program a Computer?
- •The joy of assembly language
- •C: The portable assembler
- •High-level programming languages
- •Database programming languages
- •Scripting programming languages
- •The program’s users
- •The target computer
- •Prototyping
- •Choosing a programming language
- •Defining how the program should work
- •The Life Cycle of a Typical Program
- •The development cycle
- •The maintenance cycle
- •The upgrade cycle
- •Writing Programs in an Editor
- •Using a Compiler or an Interpreter
- •Compilers
- •Interpreters
- •P-code: A combination compiler and interpreter
- •So what do I use?
- •Squashing Bugs with a Debugger
- •Writing a Help File
- •Creating an Installation Program
- •Why Learn Liberty BASIC?
- •Liberty BASIC is easy
- •Liberty BASIC runs on Windows
- •You can start using Liberty BASIC today
- •Installing Liberty BASIC
- •Loading Liberty BASIC
- •Your First Liberty BASIC Program
- •Running a Liberty BASIC program
- •Saving a Liberty BASIC program
- •Getting Help Using Liberty BASIC
- •Exiting Liberty BASIC
- •Getting input
- •Displaying output
- •Sending Data to the Printer
- •Storing Data in Variables
- •Creating a variable
- •Assigning a value to a variable
- •Declaring your variables
- •Using Constants
- •Commenting Your Code
- •Using variables
- •Working with precedence
- •Using parentheses
- •Manipulating Strings
- •Declaring variables as strings
- •Smashing strings together
- •Counting the length of a string
- •Playing with UPPERCASE and lowercase
- •Trimming the front and back of a string
- •Inserting spaces
- •Yanking characters out of a string
- •Looking for a string inside another string
- •Using Boolean Expressions
- •Using variables in Boolean expressions
- •Using Boolean operators
- •Exploring IF THEN Statements
- •IF THEN ELSE statements
- •Working with SELECT CASE Statements
- •Checking a range of values
- •Checking a relational operator
- •Boolean expression inside the loop
- •Looping a Fixed Number of Times
- •Counting with different numbers
- •Counting in increments
- •Anatomy of a Computer Bug
- •Syntax Errors
- •Fun with Logic Errors
- •Stepping line by line
- •Tracing through your program
- •Designing a Window
- •Creating a new window
- •Defining the size and location of a window
- •Adding color to a window
- •Putting Controls in a Window
- •Creating a command button
- •Displaying text
- •Creating a check box
- •Creating a radio button
- •Creating text boxes
- •Creating list boxes
- •Creating combo boxes
- •Creating group boxes
- •Storing Stuff in Text Files
- •Creating a new text file
- •Putting stuff in a text file
- •Adding new stuff to an existing text file
- •Retrieving data from a text file
- •Creating a new binary file
- •Saving stuff in a binary file
- •Changing stuff in a binary file
- •Retrieving stuff from a binary file
- •Creating a Graphics Control
- •Using Turtle Graphics
- •Defining line thickness
- •Defining line colors
- •Drawing Circles
- •Drawing Boxes
- •Displaying Text
- •Making Sounds
- •Making a beeping noise
- •Playing WAV files
- •Passing Data by Value or by Reference
- •Using Functions
- •Defining a function
- •Passing data to a function
- •Calling a function
- •Exiting prematurely from a function
- •Using Subroutines
- •Defining a subroutine
- •Passing data to a subroutine
- •Calling a subroutine
- •Exiting prematurely from a subroutine
- •Writing Modular Programs
- •Introducing Structured Programming
- •Sequential instructions
- •Branching instructions
- •Looping instructions
- •Putting structured programming into practice
- •The Problem with Software
- •Ways to Make Programming Easier
- •Breaking Programs into Objects
- •How to use objects
- •How to create an object
- •Creating an object
- •Starting with a Pointer
- •Defining the parts of a linked list
- •Creating a linked list
- •Managing a linked list
- •Making Data Structures with Linked Lists
- •Stacks
- •Queues
- •Trees
- •Graphs
- •Creating a Record
- •Manipulating Data in Records
- •Storing data in a record
- •Retrieving data from a record
- •Using Records with Arrays
- •Making an Array
- •Making a Multidimensional Array
- •Creating Dynamic Arrays
- •Insertion Sort
- •Bubble Sort
- •Shell Sort
- •Quicksort
- •Sorting Algorithms
- •Searching Sequentially
- •Performing a Binary Search
- •Hashing
- •Searching by using a hash function
- •Dealing with collisions
- •Picking a Searching Algorithm
- •Choosing the Right Data Structure
- •Choosing the Right Algorithm
- •Put the condition most likely to be false first
- •Put the condition most likely to be true first
- •Clean out your loops
- •Use the correct data types
- •Using a Faster Language
- •Optimizing Your Compiler
- •Programming Computer Games
- •Creating Computer Animation
- •Making (And Breaking) Encryption
- •Internet Programming
- •Fighting Computer Viruses and Worms
- •Hacking for Hire
- •Participating in an Open-Source Project
- •Niche-Market Programming
- •Teaching Others about Computers
- •Selling Your Own Software
- •Trying Commercial Compilers
- •Windows programming
- •Macintosh and Palm OS programming
- •Linux programming
- •Testing the Shareware and
- •BASIC compilers
- •C/C++ and Java compilers
- •Pascal compilers
- •Using a Proprietary Language
- •HyperCard
- •Revolution
- •PowerBuilder
- •Shopping by Mail Order
- •Getting Your Hands on Source Code
- •Joining a Local User Group
- •Frequenting Usenet Newsgroups
- •Playing Core War
- •Programming a Battling Robot
- •Toying with Lego Mindstorms
- •Index
- •End-User License Agreement
380 Part VII: The Part of Tens
Although most consider HyperCard the forerunner of hypertext and visual programming (long before the popularity of the World Wide Web and Visual Basic), the HyperCard programs often ran too slowly and were limited to running only on the Macintosh.
Apple Computer no longer gives away free copies of HyperCard with every Macintosh, and the company has pretty much let HyperCard drift farther into the background of neglect. Still, HyperCard’s latest claim to fame was that the designers of the best-selling game, Myst, used it to create their product, which shows that imagination is ultimately more important than the programming language you choose.
To discover more about HyperCard, visit www.apple.com.
Revolution
In the wake of HyperCard’s initial popularity, many companies offered HyperCard-clone programs. Following HyperCard’s steady decline into obscurity, most of these HyperCard-clone programs also died.
One of the few remaining HyperCard clones is Revolution, which not only runs HyperCard stacks, but also runs them on a variety of different operating systems including the Macintosh, Windows, and Linux/Unix. So if you write any programs by using HyperCard and want to preserve your programs while enabling them to run on different computers, consider using Revolution (www. runrev.com).
PowerBuilder
One of the more popular database development languages is PowerBuilder, which enables you to visually design a database application with a minimum of coding. Whether you need to share data with big mainframe computers or minicomputers, PowerBuilder may prove the product to use for making your next application. To find out more about PowerBuilder, visit www.sybase.com.
Shopping by Mail Order
You can buy language compilers directly from the publishers, but unless they’re offering a special discounted price, you’re better off buying from a mail-order house. Mail-order houses sell products at a discount — and they often don’t charge you sales tax.
Chapter 27: Ten Additional Programming Resources 381
In addition to offering a wide variety of commercial compilers at discounted prices, mail-order houses often stock a variety of programming tools that you may never find anywhere else, such as special programming editors, code analyzers, language utilities to make programming easier, copy-protection kits, and installation programs.
The following mail-order houses specialize in programming tools:
Programmer’s Paradise (at www.pparadise.com) offers a variety of programming tools for a variety of languages.
VBXtras (at www.vbxtras.com) specializes in Visual Basic add-ons and programming aids.
Getting Your Hands on Source Code
Because one of the best ways to learn anything is to learn from someone else, many programmers voluntarily share their source code so that others can benefit from their work. The Linux operating system is the ultimate example of people sharing source code.
If you can get the source code to another program, you can include its features in your own program, thus saving you time. Many companies sell programming utilities (such as miniature word processors, spreadsheets, or graphics-charting programs) that you can paste together into your own
programs. As a bonus, some of these companies also include the source code so that you can modify the program for your needs.
You can often find the source code to small programs scattered around the Internet for free. These small programs typically solve simple problems, but one of those problems may prove exactly what you need.
To find source code for your favorite language, use a search engine to search for the string “C source code”. This search string likely turns up a long list of useless Web sites and an occasional useful Web site that offers source code that you can download for free.
To help narrow your search for source code, try visiting one of the following
Web sites:
Code Guru (at www.codeguru.com) offers source code snippets to a variety of popular languages, including C/C++, Visual Basic, and Java.
Planet Source Code (at www.planet-source-code.com) provides Visual Basic and Java source code.
382 Part VII: The Part of Tens
The Delphi Source (at www.delphisource.com/) features source code just for Delphi programmers.
ABC: All BASIC Code (at www.allbasiccode.com/) provides source code for nearly all varieties of BASIC, including Liberty BASIC, QBASIC, QuickBasic, and Visual Basic.
The JavaScript Source (at http://javascript.internet.com/) offers loads of free source code for programming in JavaScript.
The cprogramming.com site (at www.cprogramming.com) offers lots of source code for C/C++ programmers to use and enjoy.
Joining a Local User Group
Programming can prove lonely and difficult in isolation. If you’re lucky (or unlucky, depending on your point of view) enough to live in a big city, you can perhaps find a local programming user group.
User groups meet regularly — usually weekly or monthly — and enable programmers to share tips and information with one another concerning their favorite language, such as C/C++, Java, Visual Basic, or Delphi.
Many user groups advertise in local computer magazines and newsletters, which you can often find in your favorite computer store. For another way to find a user group in your area, visit the Web site of your favorite compiler company (such as www.microsoft.com or www.borland.com). Company Web sites often list user group meetings in different cities.
Frequenting Usenet Newsgroups
Learning anything can prove much easier if you have some friends to help you out. If you don’t have any knowledgeable programming friends nearby, use the next best resource — a Usenet newsgroup.
Newsgroups act as electronic bulletin boards, where anyone can leave a message asking for help. Complete strangers from all around the world can give you advice or information to answer your question. If you browse through newsgroups long enough, you can often respond to other people’s messages and give them some help as well.
Nearly every programming language has a newsgroup where loyal programmers gather and swap tips, tricks, and news. Check out the following newsgroups:
Chapter 27: Ten Additional Programming Resources 383
comp.lang is a general-purpose programming newsgroup.
comp.lang.basic is a newsgroup for BASIC programming enthusiasts.
comp.lang.c is for C programming fanatics and followers.
comp.lang.c++ enables you to learn C++ from this newsgroup.
comp.lang.delphi enables you to band together with other Delphi programmers.
comp.lang.java.help is a great place for getting help with programming and using Java.
comp.lang.pascal covers Pascal programming, including some Delphi programming news and information.
This list is just a short sampling of available programming newsgroups. With a little bit of searching, you can find newsgroups for other programming languages and specific compilers such as Visual Basic, C++Builder, and RealBasic.
Playing Core War
People tend to learn faster and more effectively if they’re having fun (which is a lesson that public schools and copycat book publishers still haven’t figured out yet). Although writing a program that can calculate a second-order differential equation may improve your programming skills, it may also make you think that programming is extremely boring.
So to keep you from getting bored and to show you that programming can actually prove a lot of fun, you can play one of many programming games available for free (or for a nominal price). The purpose of programming games is to help sharpen your programming skills. If you want to win, you must learn to write the smallest, fastest, and most efficient programs — just as in real life.
The granddaddy of all programming games is Core War. In the old days, computers didn’t use floppy or hard disks. Instead, they stored data on a magnetically-charged doughnut-shaped device called core memory or just core for short.
The idea behind Core War is to write a program that you “store” in the core memory of an imaginary mainframe computer. To play Core War, each player must write a program by using a simplified version of assembly language, dubbed Red Code. Each program must search for enemy programs and erase them from the computer’s core memory. The winner is the player whose program is the last surviving program in core memory.