Chapter 1 an Introduction to Commodore 128

Chapter 1 an Introduction to Commodore 128

No. 2805 $21.95 ITABI TAB BOOKS I Blue Ridge S ummlt.. PA nco17214 Blessings crown the head of the righteous •••• Proverbs 10:6 To Mark and Paul Who have stuck with me Through it all! A special message of appreciation and thanks to Ron Powers for his constant patience, understanding and confidence. FIRST EDITION FIRST PRINTING Copyright © 1987 by David Miller Printed in the United States of America Reproduction or publication of the content in any manner, without express permission of the publisher, is prohibited. No liability is assumed with respect to the use of the information herein. Library of Congress Cataloging in Publication Data Miller, David, 1944- Commodore 128 data file programming. Includes index. 1. Commodore 128 (Computer)-Programming. I. Title. QA76.8.C645M55 1987 005.265 86-23050 ISBN 0-8306-0205-4 ISBN 0-8306-2805-3 (pbk.) Contents Program List v Preface vi Introduction vii 1 An Introduction to Commodore 128 File Types 1 Types of Files-Questions 2 BASIC Program Files 5 BASIC File Commands-Formatting and Initialization-The "Hello" Program-Questions 3 Data Files 15 Sequential and Relative Data Files-Sequential-Access Example-Questions 4 Creating Sequential Files 26 The Mailing List System-The Keyboard Input Routine-The Correction Routine-The File-Creation Routine­ The Subroutines-Debugging the Program-Program Results-Questions 5 Appending Sequential Files 44 Mai I.Adder1-Mai I.Adder2-Questions 6 Displaying Sequential Files 64 Mail.Reader2-Questions 7 Correcting Sequential Files 97 The Correction Routine-The Deletion Routine-The Write Revised File Routine-Questions 8 Additional Sequential File Techniques 130 The Math System File Output Routine-The Math Scores File Input Routine-New Commands and Terms­ Questions 9 Relative Files 159 Relative-Access Fi les-The Medical Records System-Questions 10 Advanced Relative-Access File Manipulation 186 Creating the Home Inventory File-Displaying the Home Inventory Information-Searching and Sorting the File-Correcting the Home Inventory Information-Questions 11 Planning a File System 241 The Stock Market System-Questions 12 Advanced Database Options 279 Indexing-File Utility Programs-Additional Display Programs Appendix: Answers to Chapter Questions 282 Index 286 Program List Mailing List System Programs Homeinv.Menu Mail,Menu Homei nv. Write Mail,Create' Homei nv. Read Mail.Adderl Homeinv.Search Mail.Adder2 Homeinv.Correct Mail. Reader2 Homeinv.Copy Mail.Correction V Magazine Article System Programs II Math System Programs Magazine.Menu Math.Menu Magazine.Write Math.Add Math.Subtract Math.Multiply VI Stock Market System Programs Math.Divide Stock.Menu Math .scores Stock. U pdate Real. Update III Medical Records System Program Stock.Crt Hi/Low Medical Records Stock.Dsp Hi/Low Stock. Di splay IV Home Inventory System Programs Stock. Correct v Preface What exercise is to the body, Programming is to the mind. The purpose of this book is to take some of the misery and mystery out of learning to use the Commodore 128's file structure. The book is aimed at people who would like to use the computer to assist them at home or at work by using the file capabilities of the Commodore 128 personal computer with an 80-column monitor. It is designed as a step-by-step tutorial. The book explains some things that, without adequate manuals, take many painful hours of trial and error to learn. Progress has been made in creating better file-handling techniques, and an explanation of some of these techniques is included. Upon completion of the book, you should fully understand what files are and how to use them. You will be able to create your own sequential or relative access files. Exam­ ples of both of these file types are included throughout the book. Program examples in­ clude creation programs for the stock market, mailing lists, inventories, drill and practice, and medical records. There are some very good database programs available commercially. If your needs require an elaborate database structure, you should probably use one of those programs or pay a programmer to create one for you. Reading this book will not make you capable of creating complete commercial database programs, but with practice you will be able to effectively create and use any type of fi Ie you want. I really enjoy programming and creating programs for my own use. I like the freedom programming gives me, because I can easily change or add to what the program does. I hope this book conveys some of that enjoyment and freedom. vi Introduction Books . ... (should) be read as deliberately and reservedly as they were written. H.D. Thoreau No book is magic. Merely by possessing the book, you cannot possess the knowledge of that book. Nevertheless I have tried to make it relatively easy for anyone to learn to meaningfully use the Commodore 128 personal computer. No single book will suffice for everyone, and this book makes no claim to being the exception. But I have attempted to make it useful for the beginner, as well as the more experienced Commodore 128 BASIC user. The program examples cover the areas of home, education, business, hobby, and investment. Computer vocabulary is introduced very gradually. Readers somewhat knowledge­ able about the vocabulary might find the process repetitious at first, but I have found this to be the best method for acquiring a working knowledge of the multitude of "jargon." The system approach has been used so the reader would not be overwhelmed with a large number of different application programs. The programs presented are intended to be useful as well as instructive. They build upon themselves, so that something that might appear awkward to an experienced programmer is used to help explain a concept needed in later chapters. Information for the more experienced BASIC user includes relative-access files, auto­ matic file access, initial use, file-creation techniques, sorting, and indexing. vii You cannot just absorb this information. You must read the book, reread it, and study any text and programs that are, at first, unclear. Invest time in learning how to get the most out of the Commodore 128. Many people spend a great deal of time exercising their bodies. Programming is exercise for the mind. Therefore, the time you spend in learning and using the Commodore 128 might provide benefits that go beyond intended results. Everyone seems to have difficulty with at least some aspect of using a keyboard to communicate with a computer. It does not seem to matter which computer it is or even how much typing experience a person has. And until better methods of human to ma­ chine communications are developed, we are stuck with learning to effectively use the keyboard. This initial learning process is often very important. Some people have become convinced that they cannot work with computers when, in fact, they are simply having difficulty with the keyboard. Therefore, it is imperative for new computer users to become as familiar with the keyboard as possible. Experienced BASIC users might find that they can either skip parts or proceed quickly through certain sections. I would encourage everyone to finish the book. Finally, a diskette containing all the programs presented in the book is available. You can make the diskette yourself by typing in all of the programs, but if you just want to see the programs in operation, you might want to purchase the diskette. I sincerely hope you enjoy the book and find it instructive. viii Chapter 1 An Introduction to Commodore 128 File Types There are as many definitions of the word "file" as there are kinds of files. You can quickly become confused if your understanding of the term differs from an author's intended use, and dictionary definitions are of little use in the computer world of today. Before becom­ ing involved with the computer, my understanding of a file was limited to information that was kept in a folder in a file cabinet. I think we often learn best by trying to fit that which is new into something we already understand. Therefore, I will try to explain Com­ modore 128 file structure in terms of a file cabinet. In a four-drawer file cabinet, one drawer might be for accounts payable, another could be for accounts receivable, a third for personnel information, and the fourth for inventory information, as shown in Fig. 1-1. These are used only as examples, to show that each drawer might contain different file types. The file cabinet just as easily can contain game instructions in one drawer, receipts in another, name and address information in a third, and medical records in the fourth. The idea is that a file cabinet contains different types of information. The Commodore 128's file cabinet is the disk drive and diskette. One type of file is a BASIC program file. A second file type contains only data or text. Other file types are identified by three-character abbreviations. Each diskette you use is like a file cabinet. It is set up to accept and classify these and other types of files, as illustrated in Fig. 1-2. How do you know what files are on your diskettes? The tutorial part of this book will begin by going through all of the steps necessary to find out just what files are on your diskettes. (If you are already acquainted with the procedure used to start up the computer and disk drive, you can skip the rest of this paragraph.) First, turn on the 1571 disk drive. (A 1541 disk drive will work, but the book is written specifically for the 1571.) Second, depress the 40/80 DISPLAY key and then turn on the computer.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    304 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us