home *** CD-ROM | disk | FTP | other *** search
/ Futura 3 / Futura_Issue_03_1992_09_NOSAUG_Side_A_BASIC.atr / basic2.doc < prev    next >
Text File  |  2023-02-26  |  8KB  |  1 lines

  1. INSIDE ATARI BASIC (Part 2)¢By Bill Carris.¢¢¢When your computer says READY...¢¢What your computer is ready to do is take your orders.¢¢    You will soon find, in fact, that the trick to writing BASIC programs is learning what orders to give your computer.¢¢    One of the most common instructions you will use is obtained by typing the letters...¢            PRINT¢¢which tells the computer that you want to print something on the screen.¢¢    When you type PRINT and press the 'return' key, you're telling the computer to print a blank line.¢¢¢PERFORMING SIMPLE CALCULATIONS¢¢PRINT 4+4 [RETURN]¢¢PRINT 10-4 [RETURN]¢¢(NOTE: No equal signs are needed.)¢¢The screen should look like this...¢¢READY¢PRINT 4+4¢8¢READY¢PRINT 10-4¢6¢READY¢¢¢DOING MULTIPLICATION AND DIVISION¢¢*** GO FORTH AND MULTIPLY ***¢¢The symbol for multiplication with your computer is the asterisk (*).¢¢These will not work...¢¢PRINT 5 X 7¢PRINT (5)(7)¢PRINT 5.7¢¢This will work...¢¢PRINT 5 * 7 [RETURN]¢¢will give you an answer of 35.¢¢¢/// DIVIDE AND CONQUER ///¢¢The symbol for division with the computer is the slash (/).¢¢PRINT 99/3 [RETURN]¢¢will give you an answer of 33.¢¢¢* IS THE SYMBOL FOR MULTIPLICATION¢¢/ IS THE SYMBOL FOR DIVISION¢¢¢¢PRINTING LETTERS, WORDS AND CHARACTERS¢¢PRINT "4+4" [RETURN]¢PRINT "4*4" [RETURN]¢PRINT "18-4" [RETURN]¢PRINT "HELLO FRED" [RETURN]¢¢Anything inside of quotes " " will be printed directly.¢¢The result is printed without quotes.  Trying to print quotes on the screen is possible, but will give the beginner a mental hernia.¢¢READY¢PRINT "4+4"¢4+4¢READY¢PRINT "4*4"¢4*4¢READY¢PRINT "18-4"¢18-4¢READY¢PRINT "HELLO FRED"¢HELLO FRED¢READY¢¢NOTE: You can abbreviate PRINT using a ? but beginners probably will understand their program listing better if they spell out PRINT in full.¢¢¢DIRECT MODE AND PROGRAMMING MODE¢¢With your computer, you can either DO IT NOW or DO IT LATER.¢¢Direct Mode¢¢    Instructions such as PRINT "HELLO" [RETURN] are executed as soon as [RETURN] is pressed so they are said to be in the DIRECT or IMMEDIATE mode.¢    The DIRECT mode is useful for getting quick answers and experimenting to see how the computer will react to a certain instruction.¢¢Programming Mode¢¢    A program is an instruction or a series of instructions which are not executed until you type RUN [RETURN].¢    Every time you type RUN, the program is executed again.¢¢¢THIS IS A PROGRAM¢¢10 PRINT "HELLO" [RETURN]¢RUN [RETURN]¢¢Notice the line number 10 before the print command.¢¢READY¢10 PRINT "HELLO"¢¢RUN¢HELLO¢¢READY¢¢¢STRANGE CONCEPTS RELATED TO LINE NUMBERS¢¢    Each group of instructions in a program is preceded by a line number.  Unless instructed otherwise, the computer starts executing the program at the lowest line number and works toward the highest.¢¢10 PRINT "HELLO"¢20¢30¢¢    Instead of numbering their lines 1,2,3,etc. most people like to leave room for inserting new lines later so they number them something like 10,20,30,etc.¢¢¢MORE ABOUT PROGRAM LINES AND LINE NUMBERS¢¢Replacing Lines¢¢    The easiest way for beginners to change a line is to type it over again.  The new line will replace the old line.¢¢10 PRINT "HOW ARE YOU"   (OLD LINE)¢¢10 PRINT "HI"            (NEW LINE)¢¢    As long as you use the same number, even a shorter line will replace the original one.¢¢¢Erasing Lines Completely¢¢    There's nothing to it.  Type the unwanted line number and press [RETURN].¢¢10 [RETURN]  Does away with line 10.¢¢¢The 3 Line Maximum¢¢    When writing programs, you need a new line number for every 3 lines printed on the screen.¢¢10 PRINT "YOU CANNOT PRINT MORE THAN 3 LINES OF INFORMATION ON THE SCREEN WITHOUT ADDING A NEW LINE NUMBER"¢20 PRINT "THAT IS WHY LINE 20 WAS ADDED"¢¢¢YOU'VE HAD IT TOO EASY SO FAR¢¢    You will find that it soon becomes second nature to press the [RETURN] key after making entries.¢    In order to make program listings and instructions less complicated for you to read, from this point forward, [RETURN] key instructions usually won't be shown.¢¢THIS IS NOT A COLD-TURKEY WITHDRAWL, HOWEVER.  HERE ARE A FEW MORE RETURNS JUST TO TIDE YOU OVER.¢¢RETURN RETURN RETURN RETURN RETURN¢¢¢REMark Statements¢¢THESE HELP YOU AND OTHER PEOPLE TO UNDERSTAND YOUR PROGRAM.¢¢10 PRINT "HELLO"¢20 REM THIS IS AN INCREDIBLY DULL PROGRAM WHICH SHOWS THE COMPUTER SAYING HELLO¢¢    If you type a line number and follow it with REMARK or REM, you can then type three lines of information which won't affect the program's operation.¢¢¢LIST or L.¢¢    To list the entire program, simply type LIST.¢¢¢LISTING PARTS OF THE PROGRAM¢¢    When you start working with longer programs, there will be times when you want to list just a single line or only a few lines of the program.¢    To list a single line of a program, type LIST and add the line number before pressing [RETURN].¢¢LIST 20¢¢Only line 20 will appear on the screen.¢¢20 REM THIS IS AN INCREDIBLY DULL PROGRAM WHICH SHOWS THE COMPUTER SAYING HELLO¢¢    In order to list a range of program lines, type...¢¢LIST 10,20¢¢Don't forget to use a comma!¢¢THIS WILL LIST LINES 10 AND 20 AND ANY LINES THAT WOULD HAVE BEEN BETWEEN THEM.¢¢10 PRINT "HELLO"¢20 REM THIS IS AN INCREDIBLY DULL PROGRAM WHICH SHOWS THE COMPUTER SAYING HELLO¢¢    Later, as you work with longer programs, you will appreciate this partial listing flexibility.¢¢To list a program on a printer, type...¢¢             LIST "P:¢¢¢Use LPRINT to Print on Paper.¢¢10 LPRINT "HELLO"¢20 REM THIS IS AN INCREDIBLY DULL PROGRAM WHICH SHOWS THE COMPUTER SAYING HELLO¢¢Use an LPRINT (LINE PRINT) command for obtaining a hard copy.¢¢NOTE: You cannot use LPRINT without a printer.  If you try to do so you will get an ERROR message #138, which means you printed without a printer.  What could be simpler?¢¢¢END¢¢30 END¢¢    Some types of programs require an END statement to be placed where you want the computer to stop computing.  It is not always necessary on the Atari Computer, but it is good to be aware of it so you can use it later, when you need it.¢¢10 LPRINT "HELLO"¢20 REM THIS IS AN INCREDIBLY DULL PROGRAM WHICH SHOWS THE COMPUTER SAYING HELLO¢30 END¢¢¢NEW¢¢    NEW will erase your program.  No second chances.¢¢As you can see, after you type LIST, no program appears.¢¢READY¢NEW¢¢READY¢LIST¢¢READY¢¢¢NOTE: Turning off your computer (or opening the cartridge door on a 400 or 800) will also erase your program.  Turning off the TV will not affect it, however.¢¢¢POSITION OR POS.¢¢    POSITION tells the computer where to start printing on the screen.¢    Imagine that your screen is divided into 40 blocks across and 24 blocks down.¢    If you don't use a POSITION statement before a PRINT, the computer automatically indents two spaces and starts printing on the line below the one it just finished.¢¢With POSITION, always give...¢¢POS. 10,14¢¢The number of spaces across first (10) ...then a comma...and the number of spaces down last (14).¢¢In a program, POSITION is used as follows...¢¢10 POSITION 0,0¢20 PRINT "HI"¢30 POSITION 35,0¢40 PRINT "THERE"¢50 POSITION 16,11¢60 PRINT "MIDDLE"¢¢Before you run this, press SYSTEM RESET to clear the screen.  Later you will learn more efficient ways to get unwanted words out of your display.¢¢¢STRANGE CONCEPTS - COMPUTER NUMBERING¢¢    For technical reasons, computers' internal numbering systems use 0 as the first instead of 1.¢    For example, if a computer had 12 graphics levels, they would be numbered 0,1,2,3,4,5,6,7,8,9,10, and 11.¢    As used with POSITION...¢¢40 spaces across are numbered 0 - 39.¢24 spaces down are numbered 0 - 23.¢¢¢End of part 2.¢