<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Basic Programming:</title>
</head>

<body bgcolor="#FFFFFF" link="#808080" vlink="#808080">
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="0" width="632">
    <tr>
        <td valign="top" height="106"><font size="4"><strong>Basic
        Programming:</strong></font></td>
    </tr>
    <tr>
        <td valign="top" height="28"><a name="top"></a>Link Bar:
        [<a href="#needs">What you need</a>] [<a
        href="#1basic_prog">Your 1st program</a>] [<a
        href="#2prog">Your 2nd program</a>] [<a href="#bytes">Juciy
        bytes of code</a>]</td>
    </tr>
    <tr>
        <td valign="top" height="422">Basic Programing is a good
        programing language to learn before starting a more
        advanced language, as it has a great programming theroy
        behind it. <font color="#000000">On screen</font> text is
        <font color="#FF0000">red</font>, <font color="#0099FF">code
        is blue. </font><font color="#000000">If you would like
        any sample programs feel free to email me for them.</font><h4><a
        name="needs"></a>What you need:</h4>
        <ul>
            <li>To program basic you need 3 main things:<br>
                </li>
            <li>A Computer<br>
                </li>
            <li>A program to run it (The one I use is called <a
                href="../files/qb45.zip">Qbasic.exe</a>, download
                here!- I spent hours on the net trying to get a
                version which can convert your programs to exe's,
                so here it is)<br>
                </li>
            <li>A Printer not neccessary but VERY useful for
                debuging<br>
                That all you need But some new p.cs don't like
                basic and it can cause damage (I know from
                experence) The rule is mainly if it can run dos
                programs, it should work.</li>
        </ul>
        <p><a href="#top" target="main">Go to the top of the page</a></p>
        </td>
    </tr>
    <tr>
        <td valign="top" height="1672"><h4><br>
        <a name="1basic_prog"></a>Your first Basic Program:<br>
        </h4>
        <p><font color="#0099FF">10 CLS<br>
        20 PRINT &quot;THIS PROGRAM ADDS 2 NUMBERS TOGETHER&quot;<br>
        30 PRINT &quot;TYPE YOUR 1ST NUMBER HERE&quot;<br>
        40 INPUT A<br>
        50 PRINT &quot;TYPE YOUR 2ND NUMBER HERE&quot;<br>
        60 INPUT B<br>
        70 LET C = A + B<br>
        80 PRINT &quot;YOUR TOTAL IS&quot;; C<br>
        90 PRINT &quot;DO YOU WANT TO ADD 2 NUMBERS AGAIN?
        (Y/N)&quot;<br>
        100 INPUT D$<br>
        110 IF D$ = &quot;Y&quot; GOTO 10<br>
        120 IF D$ = &quot;y&quot; GOTO 10<br>
        150 END</font><br>
        </p>
        <blockquote>
            <p>That's all you need for a basic calulator!!<br>
            Now I will explain what each line does.<br>
            Note: the number before the command is only to keep
            place e.g: you could have the number 10,20,31,
            e.t.c...before the command. Qbasic gets rid of this
            which makes life easier, and the compilier you can
            download off this site dosn't need numbers on the
            code...<br>
            </p>
        </blockquote>
        <p><font color="#0099FF">10 CLS</font><br>
        This line clears the screen.<br>
        </p>
        <p><font color="#0099FF">20 PRINT &quot;THIS PROGRAM ADDS
        2 NUMBERS TOGETHER&quot;</font><br>
        This line displays on the screen: <font color="#FF0000">THIS
        PROGRAM ADDS 2 NUMBERS TOGETHER</font> The command itself
        is: <font color="#0099FF">PRINT &quot;Your text to be
        displayed&quot;</font><br>
        </p>
        <p><font color="#0099FF">30 PRINT &quot;TYPE YOUR 1ST
        NUMBER HERE&quot;</font><br>
        See line 20<br>
        </p>
        <p><font color="#0099FF">40 INPUT A</font><br>
        This is a input command where you can type anything. The
        A is the inputs Value and when other lines call for what
        you typed they access the data kept in the Value .<br>
        </p>
        <p><font color="#0099FF">50 PRINT &quot;TYPE YOUR 2ND
        NUMBER HERE&quot;</font><br>
        See line 20<br>
        </p>
        <p><font color="#0099FF">60 INPUT B</font><br>
        Same as line 40 except it has a diffrent Value .<br>
        </p>
        <p><font color="#0099FF">70 LET C = A + B</font><br>
        The number crunching line, the most importent line of
        all. This line adds the 2 Values A$, B$ together and
        saves the answer in the Value C$.<br>
        <font color="#0099FF">LET C$ = A$ </font><font
        color="#00FF00">+</font><font color="#0099FF"> B$</font>
        The + sympol can be changed. <br>
        </p>
        <blockquote>
            <p>These are some other maths symbols: <br>
            <font color="#00FF00">-</font> To subtract Values
            from each other<br>
            <font color="#00FF00">*</font> To mulitply Values
            together<br>
            <font color="#00FF00">/</font> To devide a Value by
            another Value<br>
            </p>
        </blockquote>
        <p>Instead of having just 2 Values you could have 3 or 4<br>
        e.g: <font color="#0099FF">LET D = A + B + C</font><br>
        You can mix Values &amp; numbers together<br>
        e.g: <font color="#0099FF">LET C = A + 5</font><br>
        Also you can mix commands together e.g: <font
        color="#0099FF">LET D = A - B / C</font> So that command
        would subtract A from B &amp; the total from that would
        be devided by C.<br>
        </p>
        <p><font color="#0099FF">80 PRINT &quot;YOUR TOTAL IS
        &quot;; C</font><br>
        This line is like 20,30 &amp; 50 except it has a split
        ending.<br>
        <font color="#0099FF">PRINT &quot;YOUR TOTAL IS &quot;</font><font
        color="#FF0000">;</font><font color="#0099FF"> C</font>
        The <font color="#FF0000">;</font> splits the command
        into 2 (You could do the same thing with 2 lines) C Is
        the value to print but has no speach marks around it as
        it is a Value which displays a number which changes to
        what is being put in. Eg. If C = 10 the this will be
        displayed on screen:<font color="#FF8080"> Your total is
        10</font><br>
        </p>
        <p><font color="#0099FF">90 PRINT &quot;DO YOU WANT TO
        ADD 2 NUMBERS AGAIN? (Y/N)&quot;</font><br>
        By now you shoud know what this is.<br>
        </p>
        <p><font color="#0099FF">100 INPUT D$</font><br>
        Just another Value but for checking if you want to leave
        or not.<br>
        </p>
        <p><font color="#0099FF">110 IF D$ = &quot;Y&quot; GOTO
        10</font><br>
        This line reconises the letter Y in the Value and if it
        equals Y will goto line 10. <br>
        </p>
        <p><font color="#0099FF">120 IF D$ = &quot;y&quot; GOTO
        10</font><br>
        This line is the same as 110 except the letter Y is small
        because qbasic calls Y a letter &amp; y as a completly
        different letter. So if you had the keyboard on caps lock
        and the letter to be reconised was small the computer
        wouldn't reconise it.<br>
        </p>
        <p><font color="#0099FF">150 END</font><br>
        This line tells the computer to end the program.<br>
        You might want to look for improvements &amp; modify the
        program<br>
        Now you know how to write simple programs. </p>
        <p><a href="#top" target="main">Go to the top of the page</a></p>
        </td>
    </tr>
    <tr>
        <td valign="top" height="1254"><h4><a name="2prog"></a>2nd
        program:</h4>
        <p><br>
        This program was the 2nd program I made. It uses menus
        and is really just 4 calulators stuck together.<br>
        <font color="#0099FF">10 CLS<br>
        20 PRINT &quot;1=PLUS&quot;<br>
        30 PRINT &quot;2=SUBTRACT Q =QUIT&quot;<br>
        40 PRINT &quot;3=TIMES&quot;<br>
        50 PRINT &quot;4=DIVISION&quot;<br>
        60 PRINT &quot;PRESS A NUMBER&quot;<br>
        70 INPUT A$<br>
        80 IF A$ = &quot;1&quot; THEN 130<br>
        90 IF A$ = &quot;2&quot; THEN 200<br>
        100 IF A$ = &quot;3&quot; THEN 270<br>
        110 IF A$ = &quot;4&quot; THEN 340<br>
        120 IF A$ = &quot;Q&quot; THEN 410</font><font
        color="#00FF00"><br>
        121 IF A$ = &quot;q&quot; THEN 410</font><font
        color="#0099FF"><br>
        130 PRINT &quot;1ST NUMBER&quot;<br>
        140 INPUT A<br>
        150 PRINT &quot;PLUS&quot;<br>
        160 INPUT B<br>
        170 LET T = A + B<br>
        180 PRINT T<br>
        190 GOTO 20<br>
        200 PRINT &quot;1ST NUMBER&quot;<br>
        210 INPUT C<br>
        220 PRINT &quot;MINUS&quot;<br>
        230 INPUT D<br>
        240 LET T = C - D<br>
        250 PRINT T<br>
        260 GOTO 20<br>
        270 PRINT &quot;1ST NUMBER&quot;<br>
        280 INPUT E<br>
        290 PRINT &quot;TIMES&quot;<br>
        300 INPUT F<br>
        310 LET T = E * F<br>
        320 PRINT T<br>
        330 GOTO 20<br>
        340 PRINT &quot;1ST NUMBER&quot;<br>
        350 INPUT H<br>
        360 PRINT &quot;DIVIDED BY&quot;<br>
        370 INPUT I<br>
        380 LET T = H / I<br>
        390 PRINT T<br>
        400 GOTO 20<br>
        410 PRINT &quot;ARE YOU SURE YOU WANT TO QUIT&quot;<br>
        420 PRINT &quot;Y OR N&quot;<br>
        430 INPUT A$<br>
        440 IF A$ = &quot;Y&quot; THEN 490<br>
        450 IF A$ = &quot;y&quot; THEN 490<br>
        460 IF A$ = &quot;N&quot; THEN 20<br>
        470 IF A$ = &quot;n&quot; THEN 20<br>
        480 GOTO 410<br>
        490 END</font><br>
        </p>
        <blockquote>
            <p>This program uses every thing explained in the 1st
            program, so you can try to improve this program if
            you want, as I have lots of things which are not
            needed<br>
            You will notice I have used the letter/number
            reconising code for the method selection.<br>
            As you see I have used different symbols like I
            explained.<br>
            121 I coloured this lite green to show you that this
            line has been added into the code, which allows you
            to quit bu using the small q key.</p>
        </blockquote>
        <p><a href="#top" target="main">Go to the top of the page</a></p>
        </td>
    </tr>
    <tr>
        <td valign="top" height="1007"><h4><br>
        <a name="bytes"></a>Juicy bytes of code:</h4>
        <p><br>
        Now I am going to show bits of code and explain them.<br>
        This code comes from a program I made which randomly
        generates multiplication sums in blocks of ten. </p>
        <p><font color="#0099FF">LET A = INT(RND(1) * 10)</font><br>
        This code generates random numbers and mulitplys it by
        ten.<br>
        You can change the part which mulitplys it, if you want
        to keep the orignal number you can change ten to one.<br>
        A is the value and to use the ramdom number you use the
        value.<br>
        </p>
        <p><font color="#0099FF">LET J = J + 1</font><br>
        This line adds 1 to the value J. You can use this line
        for counting, each time the computer runs this line it
        adds 1 to it. In the program it comes from, it counts how
        many times it generates a random number.<br>
        </p>
        <p><font color="#0099FF">IF J = 10 THEN 181</font><br>
        This line comes after the one above. When the value J
        equals 10 it goes to line 181. The program has a slight
        error which only does 9 sums. The fix was: <font
        color="#0099FF">LET J = J + 1. </font></p>
        <p><font color="#000000">Change </font><font
        color="#0099FF">IF J = 10 THEN 181</font> &amp; <font
        color="#0099FF">IF J = 10 THEN J = 0</font> to: </p>
        <p><font color="#0099FF">IF J = 11 THEN 181 </font><font
        color="#000000">&amp; </font><font color="#0099FF">IF J =
        11 THEN J = 0.</font><br>
        This resets J to 0 so it can count again, if it wasn't
        reset it would count and this line: IF J = 10 THEN 181,
        it would not send you to 181 as J would be more than ten.</p>
        <p><font color="#0099FF">TPRINT &quot;THIS TEXT IS GOING
        TO BE PRINTED&quot;</font><br>
        This line comes from a program which prints things on a
        printer.<br>
        The problem with this line is it only works on dotmatrix
        as the paper on a dot matrix printer doesn't
        automatically roll out &amp; if you try to print on a
        inkjet the paper won't come out and you have to eject
        it.If you find out how to use inkjet printers please
        e-mail me.<br>
        Just use it like you use PRINT and the only differance is
        it comes out on the printer instead. Any thing you can do
        with PRINT will work with TPRINT.<br>
        </p>
        <p><font color="#0099FF">COLOR 15, 0</font><br>
        This line tells the computer what colors to use. The
        first number is for the foreground (text) &amp; the
        second number is the background. If anyone wants chart of
        all the colours &amp; their numbers, sent me an <a
        href="mailto:dodocaptain@paradise.net.nz">email</a>.</p>
        <p>By now you should be able to program simple programs
        in basic. If you want a challange try to make a hangman
        game.</p>
        <p><a href="#top" target="main">Go to the top of the page</a></p>
        </td>
    </tr>
</table>
</center></div>
</body>
</html>