home *** CD-ROM | disk | FTP | other *** search
/ Futura 4 / Futura_Issue_04_1992_11_NOSAUG_Side_A_BASIC.atr / basic3.doc < prev    next >
Text File  |  2023-02-26  |  7KB  |  1 lines

  1. INSIDE ATARI BASIC (Part 3)¢By Bill Carris.¢¢¢OPERATORS¢¢English teachers are all dishonest.  They told you that these...¢¢           :   ,   ;¢¢...were punctuation marks!¢¢    THEY'RE OPERATORS!¢¢¢THE COLON :¢¢You can use a colon to put more than one instruction in a program line.  This enables you to:¢¢- Save Time.¢- Save Memory.¢- Organise Your Programs Better.¢- Occasionally Screw Things Up.¢¢Type in NEW [RETURN] then the following one-line program.  Notice that you have condensed three instructions into one line.¢¢10 PRINT "I AM ABOUT TO PRINT IN THE MIDDLE OF THE SCREEN":POSITION 6,11:PRINT "MY DESTINY HAS BEEN FULFILLED"¢¢Here's a common pitfall:¢¢10 REM THIS IS THE FIRST LINE OF THE STOCK PROGRAM:PRINT "STOCK AND BOND ANALYSIS"¢¢Nothing following a REM statement is recognised.  When learning BASIC, keep REMs isolated on separate lines.¢¢¢THE COMMA  ,¢¢The comma helps you organise your output into columns.  When you put commas in between printed items, the computer will put the words or numbers into columns which are ten spaces apart.¢¢10 PRINT "ATARI","TEA","AND","ORANGE"¢20 PRINT "1","2","3","4"¢¢¢ATARI     TEA       AND       ORANGE¢1         2         3         4¢¢NOTE: Information on how to change the spacing between columns can be found in the section on PEEK and POKE.¢¢¢THE SEMICOLON  ;¢¢This operator allows us to join things together.  Try this program first without and then with the SEMICOLON.¢¢10 PRINT "HELLO";¢20 GOTO 10¢¢NOTE: Pressing the [BREAK] key will stop BASIC programs like this.  Typing CONT [RETURN] will make the program CONTINUE again.¢¢HELLO¢HELLO¢HELLO¢HELLO¢HELLO¢HELLO¢HELLO¢HELLO¢HELLO¢HELLO¢etc.¢¢HELLO HELLO HELLO HELLO HELLO HELLO ¢ HELLO HELLO HELLO HELLO HELLO HELLO¢O HELLO HELLO HELLO HELLO HELLO HELL¢LO HELLO HELLO HELLO HELLO HELLO HEL¢LLO HELLO HELLO HELLO HELLO HELLO HE¢ELLO HELLO HELLO HELLO HELLO HELLLO ¢etc.¢¢¢10 PRINT "GOLDPRICE=";"$385.98"¢will produce...¢GOLDPRICE=$385.98¢¢Why you do such a thing will become apparent soon.¢¢¢¢ERROR MESSAGES - THE BEST FRIENDS YOU'LL EVER HATE¢¢    Atari computers give two very useful types of ERROR MESSAGES.¢    The first is displayed when you type a line without proper punctuation, legal operators, or anything else that doesn't make sense to the computer.¢¢    Here are some common slips...¢¢PRIMT "HELLO"¢¢produces¢ERROR-PRIMT["]HELLO"¢¢On clear inspection, you will notice that PRINT is spelled wrong.¢¢    When you get this type of error message, the computer puts a marker on top of the first area in question not the error itself.  After some practice you'll spot what the computer doesn't like.¢¢¢PRINT HELLO"¢¢produces¢ERROR-PRINT HELLO["]¢¢PRINT is spelled correctly, but there's no quotation mark before the H in HELLO.¢¢¢print "hello"¢¢produces¢ERROR-[p]rint "hello"¢¢Remember you can't use lower case letters for commands.¢¢¢POS.2.5:PRINT "HELLO"¢¢ERROR-POS.2.5[:]PRINT "HELLO"¢¢How unforgiving, you used a period (.) instead of a comma between the 2 and 5.¢¢¢POS 2,5:PRINT "HELLO"¢¢ERROR-POS [2],5:PRINT "HELLO"¢¢RATS!  You got the comma right but left out the period (.) after POS.¢¢¢10 "PRINT HELLO"¢¢10 ERROR-["]PRINT HELLO"¢¢A Freudian slip; you put the quotation mark in front of the P instead of the H.¢¢¢¢PROGRAM ERROR MESSAGES¢¢    Assuming you have typed in your program, but there's something illogical about it, you will then get another type of error message when you try to RUN the program.¢¢    This error message will give you an ERROR type specified by a number and then indicate the line at which the computer had trouble executing your program.¢¢    When you get an error message with a line number, such as...¢¢10 LPRINT "HELLO"¢RUN¢ERROR 138 AT LINE 10¢¢    First look at the line specified for obvious mistakes.¢¢    Then look up the type of ERROR.  The more common errors are listed in the back of this book.  If you don't find it there, consult your ATARI BASIC Reference Manual for a full listing.¢¢    In the above case, an ERROR 138 indicates a "Device Time Out".  Someone used an LPRINT command without turning on their printer.¢¢    By the way, this may seem like a lot of trouble, but most computers give you a lot less help finding problems!¢¢¢THREE MATH TIPS¢¢¢MATH TIP #1¢¢    Computers use abbreviated forms of very large and very small numbers.  The easiest way for a beginner to deal with this is to avoid using very large or very small numbers!¢¢    You cannot, of course, do this if you are:¢¢1. An oil-rich sheik with billions to keep track of.¢¢2. A microbiologist with .000000007th of a micron of cell growth to measure.¢¢3. A masochist.¢¢    Assuming you are #3, here is a brief summary of how to translate this abbreviated notation into ordinary human notation.  VERY LARGE abbreviated numbers have:¢¢1. An "E".¢¢2. A "+" sign.¢¢3. A number after the plus (+) sign.¢¢e.g...  3.7E + 11¢¢To convert a very large number such as 3.7E + 11:¢¢1. Write the number up to the E (i.e. 3.7)¢¢2. Start at the decimal point and count, to the right, the number of places indicated by the number after the plus sign (in this case, "11").¢¢3.70000000000 (old decimal place)¢¢370000000000. (new decimal place)¢¢370000000000 is the number the computer abbreviated as 3.7E + 11.¢¢¢Very small numbers have:¢¢1. An "E".¢¢2. A "-" sign.¢¢3. A number after the minus (-) sign.¢¢e.g... 2.831E - 04¢¢To convert a very small abbreviated number such as 2.831E - 04:¢¢1. Write the number up to the "E" (2.831).¢¢2. Start at the decimal place and count, to the LEFT, the number of places indicated by the number after the minus sign (in this case, "4").¢¢0002.831 (old decimal place)¢¢.0002831 (new decimal place)¢¢.0002831 is the number the computer abbreviated as 2.831E - 04¢¢¢MATH TIP #2: Order of Execution¢¢    The computer calculates mathematical expressions in a certain order.  Calculations of the same type or of equal priority are performed from left to right.¢¢    SYMBOL¢¢1.  (   )  - Everything inside parentheses comes first, then¢¢2.    ^    - Exponentation, or raising a number to a power, such as: 5^3 which = 5 times 5 times 5 or 125, then¢¢3.   * /   - Multiplication and Division performed in order of occurence from left to right, then¢¢4.   + -   - Addition and Subtraction performed in order of occurence from left to right.¢¢Examples:¢¢    Look what a difference this can make...¢¢9*4+3=39¢¢but...¢¢9*(4+3)=63¢¢or...¢¢62-3*8=38¢¢but...¢¢(62-3)*8=472¢¢When in doubt, put parentheses around what you want done first.¢¢¢MATH TIP #3¢¢Remember when Mrs Grundle, your teacher, taught you how to write numbers with a comma after every three places?¢¢1,000,000 = one million (according to Mrs Grundle)¢¢WELL, GET WITH IT MRS GRUNDLE!!!¢COMPUTERS DON'T USE COMMAS!!!¢¢1000000 = one million (according to your computer)¢¢¢¢END OF PART 3.¢¢¢Inside Atari Basic by Bill Carris.¢(C) 1983 Reston Publishing Company.¢¢Conversion to DOC files by S.J.Murray,¢North Of Scotland Atari User Group.¢