Classic Computer Magazine Archive COMPUTE! ISSUE 39 / AUGUST 1983 / PAGE 118

Learning With Computers

Glenn M. Kleiman

After The Basics Of BASIC…

One of the questions I'm often asked is: "What do I do after I've learned the basics of BASIC?" Many people have taken introductory classes or read books about BASIC programming. They have mastered using PRINT, INPUT, GOTO, FOR-NEXT, IF-THEN, and other commands of the BASIC language and have written some simple programs. These introductions to BASIC help people gain a better understanding of computers and the nature of programming. However, they are not sufficient for learning to write the types of programs most people want to use. It's a lot like learning a foreign language: learning some of the vocabulary and grammar in school or from a book does not make you a fluent speaker of the language.

Humanized Programs

In this month's column, let's examine two books designed to help you become fluent in BASIC. Both books are for people who already know the fundamentals and want to learn more, and both teach you to develop well-structured, easy-to-use programs. These books are designed to be read while you work at the computer – the only way to learn a language, whether a human language or a computer language, is to practice using it.

Apple Backpack: Humanized Programming inBASIC, by Scot Kamins and Mitchell Waite. Byte Books, 1982, $14.95.

This book aims to help you learn to write humanized programs – the authors' term for what others call "user-friendly programs." Humanized or user-friendly programs make the computer adapt to the people who use it, rather than force the people to adapt to the computer. Humanized programs provide easy-to-understand screen displays and clear instructions. They give prompts when users are to enter responses and let users correct or change responses. They wait until users signal they are ready to proceed, and provide help if users become confused or forget some of the instructions.

After a brief introduction about humanized programming, Apple Backpack contains four chapters which explain many of the techniques for creating well-designed programs. Each chapter starts with simple components of programs and gradually builds more complex and powerful routines. Although the examples are written in Applesoft BASIC, they are all easily modified for other versions of BASIC, and the authors are careful to point out when they use commands that are idiosyncratic to Applesoft. Therefore, this book will also be useful to those who are using Commodore, TRS-80, Atari, and other computers.

Chapter 1 shows how to create well-formatted screen displays. It begins with algorithms for centering and right justifying text and for drawing borders. It then proceeds to more sophisticated routines. These include an "anti-splitting" routine for formatting text so that words are not split between lines, a routine which presents long sections of text, one screen-full at a time, and routines for formatting numbers into columns.

Chapter 2 is about "crashproofing" programs – designing them so that they behave reasonably when users give unexpected responses. This chapter shows how to create programs which check for incorrect input – a number when a letter is expected or vice versa, too large or small a number, a name with too many letters, a response that begins with a space, or one of the many other possibilities that can wreak havoc on programs that are not crashproofed.

Chapter 3 shows how to write programs which let users check and change information they have entered. It covers programming to allow users to make immediate corrections and to make changes after all the information has been entered and processed.

Chapter 4 covers providing directions and helpful information on the computer screen. It describes the need for clear instructions within the program and the value of providing prompts when people are to enter information. It also covers techniques for making extra help available when the user presses a special key.

These four chapters on programming provide an excellent blend of general discussion, examples of programming routines and complete modules, and very clear, line-by-line explanations of how each program works. While you can simply plug the provided modules into your own programs, the authors' main aim is to help you understand the modules presented and learn to create your own.

There is a fifth chapter which is not about programming at all, but about principles of writing good documentation. This chapter discusses both tutorials which help beginners get started and reference aids which serve as reminders for those who have learned to use the program.

The appendix contains two complete programs, a States and Capitals educational game and an Electronic Phone pad for storing and retrieving telephone messages. These programs demonstrate how the modules discussed in Chapters 1 through 4 can be combined into useful, humanized programs. Each program has complete written instructions which demonstrate the principles in Chapter 5.

Apple Backpack is a valuable guide for anyone who has mastered the fundamentals of BASIC and wants to become a fluent user of the language. It is at the right level for those who have been introduced to the BASIC commands and written a short program or two. Careful study of this book will help novice programmers advance a long way toward creating their own sophisticated, humanized programs.

Graphics And Sound

Techniques for Creating Golden Delicious Games for the Apple Computer, by Howard M. Franklin, Joanne Koltnow, and Leroy Finkel. John Wiley & Sons, Inc., 1982, $12.95.

This book focuses on programming the graphics and sounds that are such an important part of computer games. Its philosophy is similar to Apple Backpack in that it explores principles of good program design and coding, example program modules, and actual programs. However, the sound and graphics programming examples are unique to Applesoft BASIC, so this book is only for those who are programming Apple computers.

Entering many of the programming examples requires a great deal of typing and, of course, everything has to be exactly correct. Fortunately, a set of two disks containing all the routines is available from the publisher for $34.95.

The first of the seven chapters covers musical notes and sounds. It begins with simple routines which use the "bell" sound built into the Apple. On the Apple, more sophisticated sounds require a machine language routine. The authors provide a suitable one to be used as a musical "black box" — you are told how to use it, but not how it works. Since the book is about BASIC, but a machine language routine is required to play musical notes on the Apple, this is a good approach.

Several interesting programs make use of the black box. One plays simple tunes, another turns the Apple into a toy piano in which each key plays a different note, and a third lets you experiment with different sound effects. The sound effect program can be valuable for developing sounds to fit your games.

Chapter 2 introduces the fundamental commands for using low resolution color graphics. Chapter 3 offers an image module which lets you display low resolution images on the screen in any position and color. It also provides a set of uppercase letters and numbers created with low resolution graphics. In addition, this chapter explains how to design new images and incorporate them into the program, and it gives several example pictures.

Chapter 4 is on high resolution graphics. More on this chapter later.

Chapter 5 covers routines for handling data entry. A sophisticated, general-purpose input module is presented. By using this input subroutine within your program and setting certain variables, you can control whether the computer will accept letters (and the maximum length of the response), integer or decimal numbers (even setting the lowest and highest acceptable values), Y or N only (for yes/no questions), or any single keypress.

The input subroutine also signals when the ESC key is pressed, so you can use ESC within your programs to let the user ask for help, return to an earlier part, quit, or request other special functions. This input module is powerful and can greatly simplify writing programs requiring different types of responses from the user. It will also help you crashproof your programs.

Chapters 6 and 7 include fully developed games which use the modules from Chapters 1, 2, 3, and 5. The programs include: (1) a story game in which the computer asks a series of questions and then inserts the answers in a previously constructed story format; (2) a nonviolent version of the hangman word game; (3) a word-matching game; (4) a concentration game which uses matching color patterns; (5) a number-guessing game; and (6) a version of the memory game Simon. While none of these games will put PacMan out of business, they are all good examples of the types of educational games many people could learn to program, and they provide useful examples of how to incorporate the modules into programs.

Routine Libraries

The sound, low resolution graphics, and input modules in this book are valuable components which can simplify creating many programs. These modules, and the discussion in the book, encourage people to develop their own libraries of general-purpose subroutines and to develop well-structured programs. In addition, a great deal can be learned by studying how the games are programmed and making your own revisions and extensions of them.

Since Golden Delicious Games focuses on sound and graphics while Apple Backpack focuses on text and number processing, the two books complement each other very well. In fact, the only way they overlap significantly is that both provide routines for accepting input. A comparison of the similarities and differences of the two input routines is interesting in itself, since it lets you compare different approaches to the same goal of making it easy for people to enter information.

However, the Golden Delicious Games book contains very little discussion of how each module works. Also, there isn't an adequate discussion of high resolution graphics. The chapter on high resolution graphics is by far the shortest one in the book, and about one-third of it is spent discussing the problem of color conflicts on the Apple screen. Unfortunately, the simple solutions to this problem are never mentioned. We can conclude this month's column with an overview of hi-res graphics.

Software For High Resolution Graphics

There are three general types of software tools for using high resolution graphics from Applesoft BASIC. One type is high resolution character generators, which let you create your own character sets and display them on the high resolution screen. Such sets are useful for combining text and pictures, for using characters of different sizes and colors, for having non-English alphabets in your programs, and for adding lowercase letters to the Apple II and II+ screens. High resolution character generators are designed so that the standard BASIC print command is used to display characters from your program. You can also create characters of different shapes and combine them on the screen to form pictures. By printing, erasing, and reprinting these characters, you can even create simple animations.

The second type of high resolution tool lets you create pictures that cover all or part of the screen, save them on a disk, and bring them back to the screen from your program. Some of these tools use commands typed on the keyboard, some use joysticks or game paddles, and some use graphics tablets. In the November 1982 "Learning With Computers" column I reviewed picture-creating programs. My focus there was computer art, but the pictures created with those tools could be easily incorporated into programs.

The third type of high resolution tool facilitates working with shape tables. Shape tables save instructions to the computer for re-creating a shape you have drawn. Commands in BASIC let you place the shape anywhere on the screen, as well as change its size, orientation, and color. Shape table pictures can be placed over a full screen picture and can be used to create animations.

The following is a list of companies which market programs to help you incorporate sophisticated high resolution graphics into your programs. This list doesn't cover all those available, but I have used all the programs listed below, and each serves its intended purpose well. With these tools, you can program professional quality high-resolution graphics. In fact, the High Text and Graphics Magician programs listed below are widely used in commercial educational programs:

  1. Synergistic Software (5221 12th Ave. S.E., Bellevue, WA 98006) offers High Text, an advanced high resolution character generator which lets you use characters of different sizes and colors. It also produces a good tool, called Higher Graphics, for working with shape tables.
  2. Penguin Software (830 4th Ave., Geneva, IL 60134) sells the well named Graphics Magician. It combines picture creating, shape table, and animation capabilities.
  3. Beagle Brothers (4315 Sierra Vista, San Diego, CA 92103) has several high resolution character generator, picture-creating, and shape table programs.
  4. Edu-Soft (P.O. Box 2560, Berkeley, CA 94702) markets an inexpensive high resolution character generator program.