<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
	<channel>
		<title>5th Part: &#x22;Nostalgia&#x22; &#x22;Old&#x22; Basic Language interpreters, Commodore 64 Basic Interpreter # 1.</title>
		<link>/blogentry/53008</link>
		<atom:link href="https://www.lotterypost.com/rss/blogcomments/53008" rel="self" type="application/rss+xml" />
		<description>LANTERN's Blog: 5th Part: &#x22;Nostalgia&#x22; &#x22;Old&#x22; Basic Language interpreters, Commodore 64 Basic Interpreter # 1.</description>
		<dc:language>en-us</dc:language>
		<generator>Lottery Post RSS Generator</generator>
		<item>
			<title>Comment #1</title>
			<link>/blogentry/53008#c61293</link>
			<guid isPermaLink="true">/blogentry/53008#c61293</guid>
			<pubDate>Thu, 07 Apr 2011 03:53:52 GMT</pubDate>
			<dc:creator>LANTERN</dc:creator>
			<description><![CDATA[<p>I had some problems posting all that stuff right, it was some kind of format problem, the lines were spaced out from each other a lot.</p>]]></description>
			<category>LANTERN</category>
		</item>
		<item>
			<title>Original Blog Entry: 5th Part: &#x22;Nostalgia&#x22; &#x22;Old&#x22; Basic Language interpreters, Commodore 64 Basic Interpreter # 1.</title>
			<link>/blogentry/53008</link>
			<guid isPermaLink="true">/blogentry/53008</guid>
			<pubDate>Thu, 07 Apr 2011 03:20:15 GMT</pubDate>
			<dc:creator>LANTERN</dc:creator>
			<description><![CDATA[<p><br /><br />Commodore BASIC Character Set<br /><br />BLANK - separates keywords and variable names<br /><br />; SEMI-COLON - used in variable lists to format output<br /><br />= EQUAL SIGN - value assignment and relationship testing<br /><br />+ PLUS SIGN - arithmetic addition or string concatenation<br /><br />(concatenation: linking together in a chain)<br /><br />- MINUS SIGN - arithmetic subtraction, unary minus<br /><br />* ASTERISK - arithmetic multiplication<br /><br />/ SLASH - arithmetic division<br /><br />^ UP ARROW - arithmetic exponentiation<br /><br />( LEFT PARENTHESIS - expression evaluation and functions<br /><br />) RIGHT PARENTHESIS - expression evaluation and functions<br /><br />% PERCENT - declares variable name as an integer<br /><br /># NUMBER - comes before logical file number in input/<br /><br />output statements<br /><br />$ DOLLAR SIGN - declares variable name as a string<br /><br />, COMMA - used in variable lists to format output; also<br /><br />separates command parameters<br /><br />. PERIOD - decimal point in floating point constants<br /><br />QUOTATION MARK - encloses string constants<br /><br />: COLON - separates multiple BASIC statements in a line<br /><br />? QUESTION MARK - abbreviation for the keyword PRINT<br /><br />LESS THAN - used in relationship tests<br /><br />GREATER THAN - used in relationship tests<br /><br />{pi} PI - the numeric constant 3.141592654<br /><br />-------------------------------------------------------------------------------<br /><br />Always type NEW and hit RETURN-ENTER before starting a new program.<br /><br />-------------------------------------------------------------------------------<br /><br />A person should really read the:<br /><br />COMMODORE 64 PROGRAMMER&#x27;S REFERENCE GUIDE<br /><br />http://www.commodore.ca/manuals/c64_programmers_reference/c64-programmers_reference.htm<br /><br />http://www.commodore.ca/manuals/c64_users_guide/c64-users_guide.htm<br /><br />http://project64.c64.org/hw/c64.html<br /><br />Anyhow read:<br /><br />Hierarchy of Operations ..................................... 15<br /><br />And 10 to 17 pages<br /><br />---------------------------------------------------------------------------<br /><br />Read about the PRINT and the PRINT# keywords on pages 70 to 76<br /><br />--------------------<br /><br />EXPONENTIATION<br /><br />Use the up arrow (^) to raise a number to a power. Press the RETURN<br /><br />key after you type the calculation. For example, to find 12 to the fifth<br /><br />power, type this:<br /><br />PRINT 12^5 Key in this and RETURN<br /><br />248832 The computer displays this<br /><br />This is the same as:<br /><br />PRINT 12*12*12*12*12<br /><br />248832<br /><br />--------------------<br /><br />3.3. MULTIPLE CALCULATIONS ON ONE LINE<br /><br />The last example shows that you can perform more than one calculation<br /><br />on a line. You can also perform different kinds of calculations on the<br /><br />same line. For example:<br /><br />PRINT 3 * 5 - 7 + 2 Key in this and RETURN<br /><br />10 The computer displays this<br /><br />So far our examples have used small numbers and simple problems. But<br /><br />the 64 can do much more complex calculations. The next example adds large<br /><br />numbers.<br /><br />Notice that 78956.87 doesn&#x27;t have a comma between the 8 and the 9. You<br /><br />can&#x27;t use commas this way in BASIC. BASIC thinks commas indicate new<br /><br />numbers, so it would think 78,956.87 is two numbers: 78 and 956.87.<br /><br />Remember to press RETURN after you type the problem.<br /><br />PRINT 1234.5 + 3457.8 + 78956.87<br /><br />83649.17<br /><br />The next example uses a ten digit number. The 64 can work with numbers<br /><br />that have up to ten digits, but can only display nine digits in the<br /><br />answer. So the 64 rounds numbers that are more than nine digits. Numbers<br /><br />five and over are rounded up, and numbers four and under are rounded<br /><br />down. This means that 12123123.45 is rounded to 12123123.5. Because of<br /><br />rounding, the computer doesn&#x27;t give the same answer you&#x27;d get if you<br /><br />added these numbers by hand. In this case, the answer is 12131364.817.<br /><br />You can see the difference rounding makes.<br /><br />PRINT 12123123.45 + 345.78 + 7895.687<br /><br />12131364.9<br /><br />The 64 prints numbers between 0.01 and 999,999,999 using standard<br /><br />notation, except for leaving out commas in large numbers. Numbers outside<br /><br />this range are printed using scientific notation. Scientific notation<br /><br />lets you express a very large or very small number as a power of 10. For<br /><br />example:<br /><br />PRINT 123000000000000000<br /><br />1.23E+17<br /><br />Another way of expressing this number is 1.23 * 10 ^ 17. The 64 uses<br /><br />scientific notation for numbers with lots of digits to make them easier<br /><br />to read.<br /><br />There is a limit to the numbers the computer can handle, even using<br /><br />scientific notation. These limits are:<br /><br />Largest numbers : +/- 1.70141183E+38<br /><br />Smallest numbers: +/- 2.93873588E-39<br /><br />3.4. EXECUTION ORDER IN CALCULATIONS<br /><br />If you tried to perform some mixed calculations of your own, you might<br /><br />not have gotten the results you expected. This is because the computer<br /><br />performs calculations in a certain order.<br /><br />In this calculation:<br /><br />20 + 8 / 2<br /><br />the answer is 14 if you add 20 to 8 first, and then divide 28 by 4. But<br /><br />the answer is 24 if you first divide 8 by 2, and then add 20 and 4.<br /><br />On the 64, you always get 24 because the computer always performs<br /><br />calculations in the same order. Problems are solved from left to right,<br /><br />but within that general movement, some types of calculations take<br /><br />precedence over others. Here is the order of precedence:<br /><br />First : - minus sign for negative numbers, not for subtraction.<br /><br />Second: ^ exponentiation, left to right<br /><br />Third : * / multiplication and division, left to right<br /><br />Fourth: + - addition and subtraction, left to right<br /><br />This means that the computer checks the whole calculation for negative<br /><br />numbers before doing anything else. Then it looks for exponents; then it<br /><br />performs all multiplication and division; then it adds and subtracts.<br /><br />This explains why 20 + 8 / 2 is 24: 8 is divided by 2 before 20 is<br /><br />added because division has precedence over addition.<br /><br />There is an easy way to override the order of precedence: enclose any<br /><br />calculation you want solved first in parentheses. If you add parentheses<br /><br />to the equation shown above, here&#x27;s what happens:<br /><br />PRINT (20 + 8) / 2<br /><br />14<br /><br />You get 14 because the parentheses allow 20 and 8 to be added before<br /><br />the division occurs.<br /><br />Here&#x27;s another example that shows how you can change the order, and the<br /><br />answer, with parentheses:<br /><br />PRINT 30 + 15 * 2 - 3<br /><br />57<br /><br />PRINT (30 + 15) * 2 - 3<br /><br />87<br /><br />PRINT 30 + 15 * (2 - 3)<br /><br />15<br /><br />PRINT (30 + 15) * (2 - 3)<br /><br />-45<br /><br />The last example has two calculations in parentheses. As usual, they&#x27;re<br /><br />evaluated from left to right, and then the rest of the problem is solved.<br /><br />When you have more than one calculation in parentheses, you can further<br /><br />control the order by using parentheses within parentheses. The problem in<br /><br />the innermost parentheses is solved first. For example:<br /><br />PRINT 30 + (15 * (2 - 3))<br /><br />15<br /><br />In this case, 3 is subtracted from 2, then 15 is multiplied by -1, and<br /><br />-15 is added to 30. As you experiment with solving calculations, you&#x27;ll<br /><br />get familiar with the order in which mixed calculations are solved.<br /><br />3.5. COMBINING PRINT&#x27;S CAPABILITIES<br /><br />The 64 computers let you combine the two types of print statements that<br /><br />you&#x27;ve read about in this book. Remember that anything you enclose in<br /><br />quotation marks is displayed exactly as you type it.<br /><br />The next example shows how you can combine the types of PRINT<br /><br />statements. The equation enclosed in quotes is displayed without being<br /><br />solved. The equation not in quotes is solved. The semicolon separates the<br /><br />two parts of the PRINT statement (semicolon means no space).<br /><br />PRINT 5 * 9 = ; 5 * 9 You key in this and RETURN<br /><br />5 * 9 = 45 The computer displays this<br /><br />Remember, only the second part of the statement actually solves the<br /><br />calculation. The two parts are separated by a semicolon. You always have<br /><br />to separate the parts of a mixed PRINT statement with some punctuation<br /><br />for it to work the way you want it to. If you use a comma instead of a<br /><br />semicolon, there is more space between the two parts when they&#x27;re<br /><br />displayed. A semicolon leaves out space.<br /><br />The 64&#x27;s screen is organized into 4 zones of 10 columns each. When you<br /><br />use a comma to separate parts of a PRINT statement, the comma works as a<br /><br />tab, sending each result into the next zone. For example:<br /><br />PRINT TOTAL: ;95, SHORTAGE: ;15<br /><br />TOTAL: 95 SHORTAGE: 15<br /><br />If you have more than four results, they are automatically displayed on<br /><br />the next line. For example:<br /><br />PRINT 2 * 3,4 - 6,2 ^ 3,6 / 4,100 + (-48)<br /><br />6 -2 8 1.5<br /><br />52<br /><br />Here&#x27;s the difference when you use semicolons:<br /><br />PRINT 2 * 3;4 - 6;2 ^ 3;6 / 4;100 + (-48)<br /><br />6 -2 8 1.5 52<br /><br />You can use the difference between the comma and the semicolon in<br /><br />formatting PRINT statements to create complex displays.<br /><br />--------------------------------------------------<br /><br />So next the END KEYWORD<br /><br />NEW<br /><br />10 REM How to use the END keyword command<br /><br />12 PRINT RED , BROWN , GREEN<br /><br />14 END<br /><br />-----<br /><br />Copy that and then paste onto the C64 program and then type RUN and hit ENTER<br /><br />Get:<br /><br />RED BROWN GREEN<br /><br />READY.<br /><br />------------<br /><br />Also it can work like this:<br /><br />10 REM How to use the END keyword<br /><br />12 PRINT RED :PRINT BROWN :PRINT GREEN :END<br /><br />Copy that and then paste onto the program and then type RUN and hit Enter and the get:<br /><br />RED<br /><br />BROWN<br /><br />GREEN<br /><br />READY.<br /><br />-------------<br /><br />All of that also works on DIRECT Mode, without line numbers.<br /><br />----------------------------------<br /><br />Well you already know about the LIST keyword, it will LIST a program loaded into memory into the C64 Interpreter.<br /><br />----------------------------<br /><br />If you already have a program listing into the program&#x27;s memory and want to delete a line for example:<br /><br />Line 10<br /><br />10 REM How to use the END keyword command<br /><br />12 PRINT RED , BROWN , GREEN<br /><br />14 END<br /><br />Type line 10 without anything on it like this:<br /><br />10<br /><br />Then hit the Enter key.<br /><br />Now list the program&#x27;s lines:<br /><br />LIST<br /><br />And you will see that line 10 is now gone:<br /><br />12 PRINT RED , BROWN , GREEN<br /><br />14 END<br /><br />--------------<br /><br />To change a line for example line 12 type it again:<br /><br />12 PRINT RED , BROWN<br /><br />14 END<br /><br />Now if you RUN it you will get:<br /><br />RED BROWN<br /><br />READY.<br /><br />---------------------<br /><br />Well that is all for today.<br /><br />... &#x5b;&#xa0;<a href="/blogentry/53008">More</a>&#xa0;&#x5d;</p>]]></description>
			<category>Blog Entry</category>
			<category>LANTERN</category>
			<wfw:comment>https://www.lotterypost.com/blogentry/53008</wfw:comment>
		</item>
	</channel>
</rss>

