0% encontró este documento útil (0 votos)
142 vistas

Amiga Programming Guide

Guía de programación para ordenadores Commodore Amiga

Cargado por

Julius Erving
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF o lee en línea desde Scribd
0% encontró este documento útil (0 votos)
142 vistas

Amiga Programming Guide

Guía de programación para ordenadores Commodore Amiga

Cargado por

Julius Erving
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como PDF o lee en línea desde Scribd
Está en la página 1/ 287
Amiga™ Programming Guide. Copyright® 1986 by Que Corporation. All rights reserved. Printed in the United States of America. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system, without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, P.O. Box 50507, Indianapolis, IN 46250. Library of Congress Catalog No.: 85-63882 ISBN 0-88022-230-1 90 89 82 SY 86 87654321 Interpretation of the printing code: the rightmost double-digit num- ber is the year of the boc\ ° printing; the rightmost single-digit num- ber, the number of the book's printing, For example, a printing code of 87-4 shows that the fourth printing of the book occurred in 1987. ' | ) 1 1 j ) | About the Author > Knight Tim Knig):: of Svnta Clara, California, is the author of 15 other com- puter books as weil as numerous articles for newspapers and mag- azines. Among his publisie” titles are Graphics and Sounds on the IBM PG, Excel on Your Atari SC)X1/800XL, Basic BASIC Programs on the Adam, and Probots and Svple: The Age of the Personal Robot. Having a special interest in robots, Mr. Knight is a partner in Valley Robotics, a mail-order firm devotcd exclusively to edu- cational personal robots. iti iv Product Director Chris DeVoney Editorial Director David F. Noble, Ph.D. Managing Editor Gregory Croy Editors KathieJo Amoff Teas nine Freudenberger, MA. Fateela Fullerton Technical Editor Richard Shoemaker Founder, North American Amiga Uses (coup Table of Contents Introduction . ‘What Are the Amiga’s Capabilities? ‘What Does This Book Contain?...... Introducing the Amiga . Setting Up the Amiga. ‘Components . Hookups .. Important Dos and Don'ts ‘ising Input and Output Devices The Keyboard. ‘The Lisi: Drive and Diskettes .... ‘The Mouse Running the Amiga . ‘The Menu Bar . ‘The Workbench Window. Icons of the Workbench Window Parts of the Window Manipulating Windows Transferring Files - ‘The Workbench Tools . ‘The Clock Tool... The Notepad Tool ‘The Preferences Tool Ready for Programming. Programming in Amiga BASIC... Creating Programs Line Numbers Infinite Loops ‘The PRINT Command Using Variables ....... Numbers in Amiga BASIC . Math in Amiga BASIC Advanced Math Functions . Random Numbers .. Working with String Variables Combined Strings String Functions... Using the ASCII Character Set Creating Subroutines . Counting with Your Computer. Nesting Loops ... Experimenting with Simple Programs . ‘Writing Your Own Programs . Advanced Amiga BASIC. IF Statcu rents. Logical Operators ‘Yue ELSE Command ‘The ‘JN ERROR GOTO Command Screen Input . Retrieving a Cui: .er with the INKEYS Function . Retrieving Data with the READ and DATA Commands .. Screen Output Using Variations of the PRINT Command . Formatting Numbers. . Advanced Features for Variables . Assignments . Arrays. Program Editing Disk Input and Output Creating Graphics with Amiga BASIC .. About Pixels . Lines and Boxes Writing a Line Graph Program Using Variables with LINE Screen Colors Basic Boxes ‘Creating Random Graphics FRRLSSZS Determining Values ‘The CIRCLE Command . Solid Shapes and Patterns . Using the AREA Command Using PAINT To Fill Shapes Painting the Amiga Bear. Patterns Created with Binary Numbers . The PATTERN Command. Programmed Patterns . Accessing and Saving Graphics . Creating Superbear .. Changing Red, Green, and Blue Color Levels . Just Ask the Mouse Putting It All Together . Moving Blocks of Graphics Setting Up Patiecns . Pick Your Polygon... .+eesseeeee0 ‘A Drawing Program That Uses the Keyboard How To Set Colors with PALEY “E . ‘A Color Finder Program. .. Sounds, Music, and Speech... Amiga Sounds Off...... Aspects of SOUND Sample Sounds .......++ ‘The Musical Computer. Cranking Your Amiga Music and the Amiga. Altering the Waveform . ‘The Amiga Speaks ... Voice Changes ....+++2000006 ‘The Amiga and the Handicapped . Learning Logo Turtle Graphics. Moving the Turtle . Characteristics of the Turtle . Heading Visibility . Pen State Shane of the Turtle . 101 102 103 103 107 107 108 110 112 114 14 119 120 120 121 122 123 124 126 129 131 133, 135 136 136 137 138 138 138 139 Tile Shape Ink Color ... Keywords . Using Variables with Keywords...... Using Multiple Variables with Keywords......... Controlling the Turtle. Directional Settings . Special Symbols . . ‘The Screen’s Boundaries Multiple Turtles. . Fundamental Programming Commands . ‘The REPEAT and FOR Commands .......- ‘The DELAY Command .........45 ‘The RC and RL Commands ... ‘The PRINT Commands......... ‘The YT Command. ‘The HELP Command . File Management Commands . Saving Files . Displaying the Directo: Erasing Files .... ‘Text Commands Elements and Objects . Mathematical Functions. Decision-Making Commands. . .. Logo's Possibilities ...... Programming in C. Compiling a C Program ... : Steps for Writing a C Program ........ A Simple Example ........ Features of C Programs . Analysis of the Program Lines Library Functions . Input and Output Functions ... ‘The printf and scanf Functions . ‘The gets and puts Functions Math Functions ............ Strings and Other Data Types The stelen Function The strcmp Function . ‘The strepy Function 139 140 140 141 141 142 144 146 147 148 151 151 152 152 153 153 153 153 154 155 156 159 160 165 167 168 169 171 171 172 174 174 174 176 176 177 177 177 178 The stpchr Function... eee The strcat and strncat Functions Sample Programs . Window Maker Simple Sprite .... Copper Processor Disassembler ...... Blitter Screen Mandelbrot Explorer. Mouse Function... New &; Blitter wis * Mi: More Information abu: C .. Conclusion... Using AmigaDOs .. ‘Accessing AmigaDOS Using Directories ....... Using the DIR Command . Using the LIST Command Creating Subdirectories Using the CD Command . Setting the Time and Date Displaying AmigaDOS Information . Displaying a Message . Changing the Prompt . Listing Files........ Identifying Errors. ‘Working with Diskettes and Files Formatting and Naming Diskettes . Creating Work Diskettes . Making Backup Diskettes . Copying Files Renaming Files. ‘Adding Comments to File Names Deleting Files and Directories. Merging Files Protecting Files ....... Moving Beyond the Basics 178 178 178 179 180 182 186 189 198 = 200 + 202 205 . 2 212 + 213 . 214 214 217 220 221 271 222 223 224 . 224 224 225 226 - 226 - 227 . 227 + 228 - 229 = 230 230 + 231 + 231 - 232 10 Advanced AmigaDOS.. tecrntneeesss 233 Using Multiple Windows...........+ 233 Building Command Sequences peeeennnn 254 ‘The Editor’s Command... . 234 Commands for Sequences . a 237 Decision-Making Commands .......... 239 Making Errors Useful ... ves 242 Searching for Text ..... see 243 Making the System Pause . coon 244 ‘Making AmigaDOS Work fos Yo. 244 Amiga at Work and Play ................... 245 Word Processing .... se neeeeeeeees 245 Telecommunications seeeee 249 ‘Communications with Other Personal Computers 249 Bulletin Board Services. eeeee 250 The Source and CompuServe 253 Computer Crimes ... tees 255 Business Software for the Aiaiga 256 ‘Amiga Graphics Packages .. 259 ‘The Musical Amiga. sevens 260 dhe Entertaining Amiga. wa 261 Other Languages _ 266 Enhancements and Expansions . ‘Your Future with Amiga .. Acknowledgments ‘The author wishes to thank Hamid R. Mozzed and Mike Mass!>2 for ‘writing the majority of the C code for Chapter 7. Que Corporation is grateful to Terry Ward for providing technical expertise for Chapter 7. xii Composed by Que Corporation in Garamond and Que digital Cover designed by Lis‘unberger Design Associates Screen shots courtesy of POMUS Software, Ltd. Ottaw2, Ontario, Canada Trademark Acknowledgments Que Corporation has made every effort to supply trademark infor- mation about company names, products, and services mentioned in this book. Trademarks indicazed below were derived from various sources. Que Corporation cannot “ttest to the accuracy of this information. 1-23 and Symphony are registered trademarks of Lotus Development Corporation ‘A Mind Forever Voyaging, Cutthroats, Suspect, and WishSringer are trademarks and Enchanter, Infidel, Plnetial, Seastalker,Stacross, Suspended, The Witnes, Zork 1, Zork Tl, and Zork Il ae registered tra4-wvarks of Infocom, Ine ‘Aegis Draw is copyrighted by The Next Frontier Corp.ration. ‘Amiga and Amiga C are trademarks and Digitizer, Genlock Interfice, Graphicrat, Kickstart, Musicraft, Textcraft, The 1200 RS, Trumpeard, and “.ctench are registered trademarks of Commodore-Amiga, Inc “Archon, Arctcfox, Deluxe Video Construction Set, Marble Madness, One-on-One, Return to Atlantis, Seven Cities of Gold, and Skyfox are tradematks and Pinball ‘Construction Set isa registered trademark of Electronic Arts, ‘Commodore and Commodore 64 are registered trademarks of Commodore Flectronies, Limited, Compuserve Incomporated is a registered trademark of HAR Block, Inc ‘Compuserve Information Service is a registered trademark of CompuServe Incorporated and H&R Block, nc. CP/M isa registered trademark of Digital Research Ine Enable is a trademark of The Software Group Hitchhiker's Guide to the Galaxy is a trademark of Douglas Adanis TBM is a registered trademark of International Business Machines Corporation, Lotus and 1-2-3 are registered trademarks of Lotus Development Corporation. Macintosh is a trademark of McIntosh Laboratory, Inc, licensed to Apple Computer, Inc. and is used with its express permission. ‘MacPaint isa’ trademark and Apple Il and ProDOS are registered trademarks of ‘Apple Computer, Inc. Microsoft BASIC and MS-DOS are registered trademarks of Microsoft Corporation, Rags to Riches is a trademark of Chang Laboratories, Inc. ‘Teard, T-lisk, T-modem, and T:tape are trademarks of Tecmar, Inc. The Source is a service mark of Source Telecomputing Corporation, 2 subsidiary of The Reader's Digest Association, Inc. ‘ThinkTank is a trademark of Living Videotex, Inc. xiii “TLC Logo is a trademark of The Lisp Company. ‘TRS.80 is a trademark of Tandy Corporation. ‘Turbo Pascal and Turbo Tutor are registered trademarks of Borland International, Inc. UNIX is a trademark of AT&T. ‘Wordar is registered trademark of MicroPro Intemational Corporation. Introduction ‘You finally ma... "he decision to buy a personal computer, you bring home your new maciine, and the first question your friends ask is “What can it do?” Soon this question begins to annoy you, and you too begin to wonder: “Have I just been taken in by a trend or do J truly have a machine that can do something useful?” In my early years working with personal computers. I never veally questioned their usefulness, I simply loved using and pro, ramming computers. I recall my first computer fondly, in spite of 4s pitiful graphics, inadequate sound, and its mere 16,000 bytes of memory. And yet, when I discovered how to use machine langage to make the computer beep out a few notes of “The Yellow Rose uf Texas,” I was ecstatic. But after writing my first few computer books, I bez to realize that the home computers being sold at that time weren't Very useful for most people. The irony of that discovery was that I had been preaching through my books how wonderful computers were for ordinary people. ‘The computer industry has come a long way since then, and today I no longer have to question the usefulness or value of personal computers. The technology has progressed very quickly, bringing to the public such machines as the Apple II®, the IBM® PC, and the Macintosh”. These computers were major milestones in the indus- try, and cach machine that was introduced had capabilities that were improvements over its predecessor. In particular, significant im- Provements were made in the areas of graphics, sound, speed, mem- ory capacity, and mass storage capability. Among these new computers, the Amiga™ from Commodore-Amiga, Inc,, stands out as one of the most powerful and exciting personal ‘computers in existence today. The more you know about computers, the more astounded you are at all the Amiga is capable of doing 2 AMIGA PROGRAMMING GUIDE What Are the Amiga’s Capabilities? : ‘Marking another major milestone in the personal computer industry, the Amiga features many powerful capabilities at a low cost. Among, the Amiga’s capabilities are © High-resolution graphics with 4,096 available colors © Sev and music generation in stereo with as many as fou “vow. s" (channels) © Easy operauo. with the mouse © A full 512K of user memory © A complete keyboard with cursor-control keys and a numeric keypad © ‘The sophisticated and powerful 68000 Motoro!” microprocessor ‘Two of the Amiga’s strengths are particularly outstanding: graphics and sound capabilities. Graphics are the pictures th. computer can produce on the screen. By using the Amiga’s graphics commands, you can draw a variety of shapes and colors on the screen with ‘surprising ease. The sounds you can produce with the Amiga can be sound effects in a game or musical pieces, You can create music using as many as four separate instruments playing simultancously. ‘To program the computer to make graphics and sounds and to serve other usefal functions, you need to Ieam the fundamentals of three ‘computer languages: Amiga BASIC, TLC™ Logo, and C. The Amiga Programming Guide concentrates on the Amiga’s graphics and sound capabilities, as well as on the computer languages you need to leam to use the Amiga What Does This Book Contain? ‘This book is organized so that you gradually learn about program- ming as you work your way through cach chapter. You need not be an expert in computer programming in order to learn from this book because it is a tutorial, not a reference guide. Through pro- gramming examples and descriptions of keywords (specific words in a computer language that cause the computer to perform tasks), you can learn, step-by-step, the fundamentals of programming. This INTRODUCTION 3 knowledge will give you the basic foundation, from which you can use your own imagination to build and create more powerful pro- grams. A brief overview of the material presented in this book follows In Chapter 1, “Introducing she Amiga,” you will lear how to set up the Amiga, use the mouse and keyboard, and use the Workbench program. Chapter 2 provides an introduction to the fundamental concepts of programming in Amiga BASIC, the ianguage that comes with your computer. You will learn abo line nnmbers, variables, and some simple commands. Chapter 3, “Advanced Amiga BASIC,” proviors cxptanations of vari- able arrays, program development, and other more advanced topics. ‘The material in this chapter will help you begin writing 12.re 50- phisticated programs. Because much of the Amiga’s power is in its graphics capability, all of Chapter 4 is devoted to Amiga BASIC’s graphics commands and ways (0 use them, You easily can produce sounds, music, and speech through Amiga BASIC commands. In Chapter 5, “Sounds, Music, and Speech,” you will !earn how to use these commands in your own programs. Chapter 6 teaches you the basics of Logo. This language is popular both for children and adults who are interested in artificial intel- ligence. Even if you don't own a Logo software package, you still can profit from a look at how another programming language works. C is a fast, powerful language that is popular among professional programmers. Chapter 7, “Programming in C,” gives you a brief introduction to the language and explains what you will need to use it. ~ Chapter 8, “Using AmigaDOS,” explains the disk operating system that is included with your Amiga’s software. AmigaDOS can help you ‘manage your computer's information efficiently. To learn even more advanced commands for the disk operating sys- tem, you can explore the commands and DOS program descriptions presented in Chapter 9, “Advanced AmigaDOS.” Finally, Chapter 10, “Amiga at Work and Play,” contains information that can help you make the Amiga a useful tool for your home or ‘slice, This chapter alco offero Mews for volug your Auulga for car 4 AMIGA PROGRAMMING GUIDE tertainment. Once you understand all that the Amiga is capable of doing, you will be able to answer confidently the question “What can it do?” The power of the Amiga is immense, and after you have finished reading this book, you will have the knowledge to begin tapping that power. i Introducing the Amiga ‘The Amiga is one of today’s most sophisticated personal computers for the home and for the small business (see fig. 1.1). This computer features unparalleled graphics, versatile sounds and music, easy-to- use input and output devices, a fast microprocessor, and a library of powerful sotiware. The combination of these features, made pos: sible by recent advances in high technology, make this computer an excellent value. SPU ore a i Orr i Fig. 1.1. The Amiga. Although the manual that comes with the Amiga system provides general instructions for setting up the system, using the Work- Dench®, and programming in Amiga BASIC, these items—as well as 6 AMIGA PROGRAMMING GUIDE ‘other topics—are covered in much more detail in this book. In this chapter, you will learn how to set up the Amiga; how to use the keyboard, the disks, and the mouse; and how to start running the computer. Setting Up the Amiga Before setting up the computer, you must find a place to put it. Although this may seem to be a minor topic, giving the location some advance thought can prevent cost!,; acc. teuts and aching backs. Some important requirements for the i. “tou of the com- puter are the following: 1. The surface should be smooth and flat with plenty of room for laying down such items as books, diskettes, and program listings. 2. The location should be near an electrical outlet so that Lue computer can be plugged in without the risk of someone's tripping over the cord and pulling out the plug. 3, Your computer workstation should be equipped with a comforiis!~ chair, preferably an adjustable office chair like you would use at a typewriter table. If you spend a few hours at your computer sitting on the old dining room chair, the ache in your back will tell you why an appropriate chair is important for your workstation. A comfortable office chair, which has adjustable height and back support, puts minimum stress on your back. Adjustable office chairs are available in most office supply centers for less than $100. 4. If possible, your electrical outlet should be equipped with a surge protector, which you can purchase at most computer outlets. This device eliminates the changes in electrical power that can cause loss of, information in the computer's memory. Components Once you have designated an appropriate workstation, you can begin to arrange the computer's components and to make the necessary hookups. ine Amiga computer comes with the following components: INTRODUCING THE AMIGA z The main computer unit and power cord: The main unit contains all the hardware of the computer. The microprocessor, memory, input/output electronics, and the rest of the actual computer are housed in this case. The keyboard and cable: The Amiga keyboard resembles a typewriter keyboard but has extra keys, such as the numeric keypad, function keys, and other special keys. The mouse: To move the computer's pointer around the screen, you use the mouse. By moving the pointer to selections on the screen and pressing the left button on the mouse, you can select options and open programs easily. Three disks: Included with your Amiga system are three disks: Kickstart®, which gets the computer running when you first ture it on; Workbench, the “home base” for getting other programs up and running; and Amiga Extras, which has the Amiga Tutor and the Amiga BASIC programming language. Parallel ‘Audio TV Modulator Connector Connectors. Connector f\ 4 \ ‘a Keyboard em: GG cea: @ «Mil Connector 5 Disk Drive Serial RGB Fig. 1.2. The back of the Amiga. Connector Connector Connector Connector 8 AMIGA PROGRAMMING GUIDE Hookups ‘When you have all your components out of their cartons, you can begin setting up the Amiga and making the necessary hookups. Fol- Jow these instructions in the order given, and in a few minutes your ‘Amiga will be up and running. (Refer to fig, 1.2 for the locations of the connectors.) 1. Place the main computer unit on the desk that you will be using. Make sure that the slot for the disk drive is facing you. Now take the cable for the keyboard (the ‘one that resembles a telephone cord) and plug the straight end into the lefimost connector on the back of the main computer unit. 2. Set the keyboard (so that it faces you) in front of the ‘Amiga and p'ug the free end of the keyboard cable into the connector located on the extreme left side of the back of the keyboard. The keyboard is now hooked up to the Amiga, and you can tuck the keyboard cord underneath the main computer unit, which has an opening for the ca>le to pass through. If you want to tilt the keyboard, put down the legs on the right and left sides underneath the keyboard. When you put these legs back up (so that the keyboard lies flat), you can slip the keyboard completely underneath the main computer unit for storage. This feature is, convenient if you need the extra space when the computer is turned off 3, Now take the mouse and set it on the desk to the right of the keyboard. (If you are left-handed, you can place the mouse on the left side if you prefer.) Plug the end of the mouse’s cord into the connector labeled “1" on. the right side of the main computer unit. Your mouse is now attached and ready to use. When you start using the computer, you may discover that the computer is sluggish and is not as responsive to the mouse as you would like. If the problem stems from the computer not being sensitive to the mouse’s movements, you can solve this problem casily; see the section titled “The Preferences Tool” later in this chapter. 10 AMIGA PROGRAMMING GUIDE connecting a television to a computer vary from TV to ‘TY, so check the instructions that come with the modulator to find the proper procedure. 5. Now you are ready to bring the Amiga to life. Plug the six-sided plug on the power cable into the corresponding connector on the back of the main computer unit; then plug the other end into a three- prong electrical outlet. To turn on your computer, flip the switch on the left side of the main computer unit. monnec “ug a sterco to the Amiga is optional. If you do 50, nu. ~vex, You can enjoy the results of the programs in Chapter » in stereo sound. To hook up your stereo, get two phono cables and, on the back of the main ‘computer unit, plug one cf "hem into the circular connector for the left stereo cisannel and plug the other into the circular connector for the right stereo channel (see fig. 1.2). Then take the other ends of each cable and plug them into the correspe connectors of your stereo system. Important Dos and Don’ts Before you go any farther, stop and memorize the following three rules for using your Amiga. Learn and live by these rules, or else you will find yourself with a trashed disk or computer. If you have just turned off your computer, wait five seconds before turning it on again. Never do a software reset when a disk—especially the Workbench disk—is running. A software reset, which you do by pressing the CTRL key and two ‘Amiga keys simultaneously, is a sort of “panic button.” You use this procedure to get out of any mess you may get into with the Amiga (such as when the Amiga gets stuck in a routine). Pressing CTRL and the two Amiga keys is fine as long as the disk drive isn’t running. If the disk drive is running, you could accidentally wipe out your information and programs. Never remove a disk when the disk drive is running. If your files are not closed and you remove the diskette, it will be rendered uscleao. Therefore, whenever the dick drive is running—the While, you will surprise Yourself with just how er you can enter numbers, Function keys. The function keys do different things in different programs. In 2 Word processing Program, these Keys may be used for Geleting words, roving pee ofa 12 AMIGA PROGRAMMING GUIDE Function Keys Left ALT Key Right Cursor- Amiga Moverent Left Right Numeric Ke Keys ‘Amiga ey ALT Key Keypad Key Fig, 13. The keyboard. document around, or saving and loading files. In a business program, however, the function keys may be used for adding columns of figures and doing mathematical operations. The documentation provided with the specific software tells you what functions, if any, the function keys serve. Cursor-movement keys: To move the blinking cursor (the blinking box showing where you are working on the screen), use these up-, down, left., and right-arrow keys. As mentioned earlier, these keys also are used with the Amiga keys and the SHIFT key to move the pointer around the screen without using the mouse. CAPS LOCK: If you want to type all capital letters, press this key. The red LED built inside the key will light up. When you want to go back to regular uppercase and lowercase letters, press this key again, and the light will tar off INTRODUCING THE AMIGA 13 Other special keys: Like the function keys, a number of other keys perform different tasks, depending on the software running on the computer. These keys include the CTRL (Control), ALT (Alternate), Amiga, and ENTER keys. Others special keys are ESC (Escape), which usually gets you out of whatever function or program you are in, and BACKSPACE, which moves the cursor back one space, removing the character the cursor lands on. The Disk Drive and Diskettes ‘One of the most important input/output devices /.- your Amiga is the disk drive. The small 3 1/2.inch diskette that your aiuia uses holds more than 800,000 pieces of information. To help you avoid accidentally erasing an important file or copying over data, the diskette comes with a protect tab. By shifting this tab, you can protect or unprotect the diskette. If you don't want the disk drive to Write anything on a diskette, move the protect tab toward the top of the diskette (so that you can see through the small hole in its upper right corner). If you don’t want the diskette to be write- protected. close the hole by pushing the protect tab back down. The diskette is delicate and should be handled carefully. Although the diskette itself is sealed and protected from the outside envi- ronment by its metal slide, you still should not subject the diskette to heat, any kind of magnets (which include telephones, speakers, and motors), or smoke. Also, be sure that you never touch the actual diskette after moving the metal slide and exposing the plastic dis- kette itself. Touching the diskette almost definitely will ruin it. The Mouse e Another important input device is the mouse—a pointing device that translates your movements into movements for the pointer on the screen. The mouse works by detecting the movement of a rub- ber ball inside the mouse; as the ball rolls in a certain direction, the mouse translates the direction into a change in the x- and y- coordinates of the pointer on the screen. To keep the mouse in good working order so that your computer does not respond sluggishly, you need to give the mouse special care. Every couple of weeks, you should go through the following procedure: 14 AMIGA PROGRAMMING GUIDE 1, Turn the mouse upside down and slide the piece of plastic holding the ball inside the mouse. 2. Lift the piece of plastic off the mouse. 3. Tum the mouse over and catch the ball. 4, Moisten a cotton swab with alcohol or a window- cleaning solution and clean the rollers inside the mouse where the ball used to be. 5. Wipe off the rubber ball and reni.c ‘* inside the mouse; put the plastic cover back . Running the Amiga ‘When your Amiga is first turned on, you should see a graphics picture of a hand holding a disk called Kickstart. This picture is your signal to pot the Kickstart disk in the drive. Insert the Kickstart disk with the ..etal slide facing forward and the label facing up. (This is the way you insert all disks.) ‘Anc? you insert the disk, the Amiga reads from the Kickstart disk. The disk drive light stays on as long as the program is reading, In a few seconds, another hand appears on the screen; this hand is holding a Workbench disk (see fig. 1.4). Make sure that the drive light is off and then eject the Kickstart disk by pressing the button on the front of the disk drive. Insert the Workbench disk. In a few ‘moments, the screen displays a title bar and a Workbench disk icon, (An icon is a picture representing a program or some other disk or file.) Now work with the mouse for a few moments to get familiar with its operation. The mouse is your key to easy control of the Work- bench features. Try moving the mouse around on a flat surface, and watch how the arrow on the screen moves relative to your move- ‘ments. When you move the mouse away from you, the pointer arrow ‘moves up the screen; when you move the mouse around in a circular motion, the arrow moves in the same way. The arrow will not go beyond the boundaries of the screen. If you need to move the arrow farther than the space on your desk allows, simply lift the mouse up and move it over. For instance, if you want to move the arrow to the extreme left, but your keyboard prevents you from moving the mouse any farther to the left, you simply lift the mouse up and act it down aa far to the right a¢ you can, You then have room to go to the left again. After you have worked with the mouse for a Fig. 14. Ieon telling you to insert the Workbench disk, INTRODUCING THE AMIGA 15 while, the movements will become natural, and you will wonder how computer owners evr managed without a mouse. ‘You use the buttons on the mouse to select items. You almost always will be using the left button. Assume cizt you want to select an icon from the Workbench disk. Using the mouse, you move the arrow to the Workbench icon and click the left mouse button. This action inverts the icon and tells the computer you have selected that icon. However, nothing happens until you open the icon. To open the icon, you press the left mouse button twice without pausing between clicks (doublectick). The Workbench disk icon then explodes into a window where you can see a directory of all the files on that disk. Go ahead and use the mouse to point to the Workbench disk icon. ‘The pointer must be pointing to some specific part of the disk icon, not just in its general direction. Once you have positioned the pointer on the icon, double-click the left mouse button and watch as the window forms out of the exploding icon. Another use of the left mouse button is to drag an icon. As the term suggests, dragging an icon means that you pull it around on the screen, For example, if you have a file you want to put in the trash, you move the arrow to the file’s icon, hold down the left mouse button, and move the mouse to drag that icon to the Trashcan. The file then is disposed of. Trv moving the icons thar are in the window Don’t move the icons outside of the window, and don't put any of 16 AMIGA PROGRAMMING GUIDE them on top of the Trashcan (or they might get destroyed acci- dentally), Just move the icons around a bit until you see how the dragging process works. Using certain keys on the keyboard, you can accomplish many tasks without using the mouse. (You may want 10 do this, for instance, if your mouse is broken.) Notice the red A Amiga keys to the right and left of the space bar on the keyboard. To move the pointer, press either Amiga key with one of the cursor-movement keys (the keys with up, down, left, and right arrows). To select an icon, you position the pointer on the icon and press the left Amiga key with the left ALT key. To open a file, you hold down the left Az key and quickly press the left Amiga key twice. To speed up the move ‘ment of the pointer, you can hold down the SHIFT key while you use the Amiga and cursor-movement keys. The Menu Bar Select the icon for the Workbench disk and press the right mouse button. Now notice the Menu Bar that appears on the top of the screen. On the Menm Bar are the words Workbench, Disk, and Spe- cial. These menu titles are positioned over three invisible menus ‘You can make these menus visible by holding down the right button ‘on the mouse while pointing to a menu title (see fig. 1.5). Fig, 15. The Workbench window otek puitdouin moms seloctod INTRODUCING THE AMIGA. 17 ‘When you pull down the Workbench menu, you see the following choices: Open Opens the icon selected ‘ Close Closes the file or disk you are working with Duplicate Makes a copy of a disk Rename Changes the name of the icon or disk Info Gives you information regarding the current disk or program Dix-rd Throws away the icon you have selected Because having Leckup copies of your disks is so important, the Duplicate command deserves special attention. As I mentioned ear- lier in this chapter, I once accidentally destroyed my Workbench disk. If I had made a backup of Workbench, I would not have had any problem; instead, had to make a trip to the dealer to get another copy of the disk. In any situation, you should have your own backup copy of a disk. ‘When you choose Duplicate, the computer tells you when and how often to swap the disks in order to finish the copy. The computer guides you through the entire copying process by instructing you which disk to insert or eject at any one time, (If you are frtunate enough to have 2 two disk drive system, you do not need to worry about swapping disks in and out of the drive. You simply drag the file's icon to the second disk drive icon and follow the menus.) ‘The menu under Disk offers the following options: Empty Trash Permanently gets rid of the unwanted files you have put into the Trashcan. The Trashcan icon must be selected with the mouse before this command will work. Initialize Formats a new disk or erases an old one completely. Be careful when you choose this option; if you go through with this selection, you will erase all the data on the disk in the drive, Under Special, you have these menu options: Clean Up Neatly arranges the icons in a window 20 AMIGA PROGRAMMING GUIDE window around to different parts of the screen. In the middle of the Drag Bar is the Disk ener, which tells you the name of the diskette. Sizing Gadget: At the lower right comer of the window is the Sizing Gadget, which lets you shrink or expand the window. Point to the Sizing Gadget, hold down the left mouse button, and move the mouse. The size of the window chang:s on your screen. You can make the window wide and saci toll and thin, or very big Disk Gauge: v.. “he !+ft side of the window is a “fuel meter” for each diskei'*. The Disk Gauge indicates how full the diskette is. When the Disk Gauge shows that your diskette is nearly full, you should begin using another diskette in order to ensure that you have plenty of room to work with, Scroll Arrows: In the comers of the window are arrows pointing left, right, up, and down. You can move the contents of the window around by pointing to an arrow and holding down the left mouse button. If, for example, you can’t see all the files in a window because they stretch beyond its boundaries, you can point to the appropriate arrow (corresponding to the direction you want the contents of the window to move) and hold down the left mouse button. Back and Front Gadgets: Windows often overlap one another. If you want the current window to be in front of another window, move the pointer to the Front Gadget, located in the upper right comer of the current window, and click the left mouse button. If you want the current window to hide behind another window, select the Back Gadget box just to the left of the Front Gadget box. You will sometimes see on the window a pufly icon filled with Zs. ‘This icon indicates that your Amiga is busy with an operation and can't be interrupted. When the computer is ready to respond to ‘your commands again, the snoring icon changes back to a regular pointer. INTRODUCING THE AMIGA 21 Manipulating Windows ‘To make sure that you have a good understanding of windows, use the mouse to open the drawer called Demos. Then open all three Program icons in the Demos window: Dotty Window, Boxer Win- dow, and Lines Window. The Dotty Window draws randomly col- ored dots inside the window; the Boxer Window draws randomly colored boxes inside the window; and the Lines Window draws random lines bouncing around the window. The functions of all three windows go on simultaneously (sez Oy. 1.7), which demon- strates the important concept of multitaski7 the computer's ca- ability to carry on more than one function at a tuc.7 Multitasking is possible on the Amiga because of an advanced coprocessor chip, which is important to you in only one respect: you can get several things done at once. For instance, you can receive a program over the telephone line, work on a spreadsheet, and print a letter all at once. Go ahead and experiment with these three windows. Move them around, expand them, overlap them, and do whatever else you think would be fun and would help you lear more about the functions of windows. Once you have finished experimenting, close the three Program windows one at a time. 22 AMIGA PROGRAMMING GUIDE Transferring Files When you have more than one window on the screen, you can transfer files from one window (which might represent a disk or drawer) to another. For instance, if you are working with a single disk drive system, and you want to copy the program POLYSCOPE from one disk to another, you simply drag the POLYSCOPE icon from one disk window to the other disk window. The computer then gives you instructions that tell you what disk to insert at what time in order to copy the POLY.rs ai. displayed to the left of the words Reset Colors. Click 7 ure of these colors in order to modify the level of red, green, ux blue that the color has, and then use the arrows to adjust the color to your liking. If you prefer different colors, this is the section vf Preferences that you use to make the adjustments. If you decid that you would rather go back to the colors you were using, select the Reset Colors box. Display Centering: In the center of the Preferences window is a box, and near the middie of the box is a symbol that resembles a corner mark. With this symbol, you can change the position of what is being displayed. If your monitor or television is cropping off some of the display, you can use this tool to make the needed adjustment. Move the pointer to the symbol and hold down the left mouse button as you drag the screen to a better position. Printers: Choosing this part of the Preferences window brings an entirely new window onto the screen (see fig. 1.9). With this window you can tell the computer what kind of printer you are using; what kind of paper you want to use; whether the print should be letter-quality or dot- matrix; what the pitch, space, left and right margins, and paper size are; whether you will be printing graphics; and what kind of printer port you are using. Edit Pointer: If you want to change the appearance of your pointer, you can select this option and create your own pointer. The Amiga will show you how to create a new pointer by using the mouse and any of the four available colors. ‘When you are satisfied with the choices you have made in Prefer- ences, you can select Save to put those choices on the disk. If your choices are temporary, choose Use; the computer will use your | ' Fig. 1.9. The printerselecion window! INTRODUCING THE AMIGA 27 6 ti iis EEN choices until it is tumed off, at which time the Amiga will “re- member” only the most recent preferences stored on the disk drive. If you decide that you want everything set back the way it was when. you bought your Amiga, choose Reset All. If you want to save to the disk the options you last specified, select Last Saved. (‘These options are located in the upper left corner of the Preferences window.) Finally, if you decide not to save the settings you have chosen, select Cancel. Any of these selections will return you to the Workbench. You should spend some time experimenting with the Preferences. ‘You always can reset them to their original positions. One interesting feature you should note about working with win- dows and desktops is that entire screen displays may-be moved just as easily as windows. Right now, move the pointer up to the top of the screen to the words fini gaUorkbench. Hold down the left mouse button and drag the screen down as far as you like. You can move the screen up the same way. When you have several screens in op- ration, you can shift them up and down in order to work with the one you want. Moreover, each screen has a Front Gadget and Back Gadget (in the upper right corner), so you can overlap screens just as you do windows. Finally, notice that the Amiga will also tell you (at the top of the screen) how many bytes of memory you have left to use. 28 AMIGA PROGRAMMING GUIDE Ready for Programming ‘Now that you have set up your computer and you have experimented with using the Workbench desktop and its. windows, you are ready to undertake some programming, Although you may not have all the Ianguages discussed in this book, you definitely have Amiga BASIC because it comes with your computer. To do the programming dis- cussed in Chapters 6 and 7, you will have to purchase the other Ianguages used. However, even if you don’t have all the languages, you will find reading those chapters worthwhile. Throughout the ‘chapters in this book, you wi"! exp:9re many different ways to use the potential of the Amiga. 2 Programming in Amiga BASIC ‘Amiga BASIC, the Amiga’s version of BASIC, is one of the easiest languages to use with th> Amiga. BASIC (the acronym for Beginner's All-purpose Symbolic In-t:uction Code) always has been the most popular microcomputer language for beginning and intermediate users. Although BASIC is not the fastest language available, it is pow- erful and easy to Icamn. Amiga BASIC is essentially the BASIC language with some enhancements. Besides heing one of the best and most advanced versions of BASIC available, Amiga BASIC is easy to master. Because the words of the language are so much like English, you should be writing simple programs within half an hour. This chapter helps you learn the Amiga BASIC language through the step-by-step creation of short sample programs that demonstrate what different keywords do. ‘Two methods are available to tell the Amiga what to do when you are using Amiga BASIC. You can type commands from the keyboard or you can create a program. To use the language in either way, you first double-click the Amiga BASIC icon. You will see two windows: Output and List. The Output window displays the results of your programs. You also use the Out- put window to enter commands directly (for example, PRINT HELLO”). The List window, on the other hand, is where you type or edit a program. You can open either window by moving the mouse pointer to that window and clicking the mouse button. At the top of the Amiga BASIC screen is the Menu Bar, which pro- vides a variety of options. You can do such tasks as suspend a pro- 29

También podría gustarte