| PROGRAM:
SCREEN |
#or
whatever name you chose in place of screen |
| : |
#each
line of code starts with a : |
If
you hit enter you'll end up with a colon on the next line too.
And for each time you repeat you'll have a new colon (this part
should really mess with anyone's head who has studied human anatomy
in school). Now since I know you have been enjoying yourself hitting
the ENTER key a few million times I'm going to show you how to
get rid of all those colons. The first is simply deleting the
program and making a new one. Whenever I am telling you how to
find something I will seperate each button push by a - and if
a second or alpha is chosen before then I'll name the letter on
top. First of all to exit out of the code window click 2nd-QUIT.
You never have to save your code it is always saved automatically
when you exit. Next it is 2nd-MEM-2-7. Notice I used the numbers
to select the choices in the menu and I didn't scroll down to
find each one. If you memorize the menu numbers when you are programming
it will go alot faster. Alright now you just use the up or down
arrows and select the program you no longer want and hit delete
and then when it asks "Are you sure?...cause if I were you
I wouldn't do that...I'd talk it over with a counselor or something
and" Quickly choose yes. Assuming you actually want to delete
the program. Now you need to get back into the code window (if
you didn't delete the program). You do this by going to PRGM-scroll
right to edit-Choose program from list. Then that familiar old
code window I illistrated above should pop up.
So
Where Does This Code Stuff Come From? Is It Like Morse Code? S.O.S.
The
majority of code we will be using will come from one of 5 places:
1.)
The code which is found when in the code window and you press
the PRGM button again. There are 3 collumns here. The first is
for setting up loops, the second "I/0" stands for Input/Output
and does just that (displays messages on the screen and takes
user input). The last collumn is PRGM and this is a list of programs
that you can run from within your program (which I will call a
prog from now on... program is too big to type alot). Look through
this menu a bit before we begin and make logical word associations
(like Disp means Display and Lbl means Label...things like that.)
2.)
By using 2nd-Test you'll find the second most used section. It
has 2 columns also. The first one is all that greater than less
than stuff they pumped into your head in Fourth grade and the
second Collumn has logical tests. I'll talk a bit more about these
later.
3.)
The letters found on the keypad...A,B,C etc.
4.)
The numbers found on the keypad...1,2,3 etc.
5.)
Things found under the VARS button (strings in particular)
6.)
Alright I know I said five places but there is a 6th that is used
alot also. It is only used in graphical games, not in those boring
games like Hick Quest or Drug Cartel. These are the fun games
like Duck Hunt and bowling where you actually get to see what
you are doing. The info for this is found in 2nd-DRAW, and I'll
explain it a bit better near the end of this article since it
is the part I understand the least.
Eurokea
I've Hit The Code Jackpot....Now Where Do I Put This Mumbo Jumbo?
This
is what programming is all about...where do I put this stuff?
I'm going to type up the source code for a simple screen saver
type program and then go back and disect it. Remember anything
after a # is mean to be read not typed.
SCREEN SAVER
PROGRAM:
SCREEN
:"SPAM SPAM SPAM"->Str1
:Lbl 1
:ClrHome
:1->A :Lbl 2
:Disp Str1
:A+1->A
:If A=8
:Goto 1
:If A<8
:Goto2 |
This
stores spam as a string
This labels the following code as "1"
Clears the main screen (where you do math)
1 is stored as A (A now equals 1)
The following code is labeled "2" ("1" also)
Displays String 1 (which is spam)
A is one unit larger than before
same as "if str1 has been displayed 8 times"
This will clear the screen and start over
If Str1 has been displayed less than 8 times
This displays str1 on the next line again |
Alright
I'll start explaining where everything is found right now along
with what it is actually doing. First of all if you ever run into
the problem where my instructions to find a command aren't well
written then go to 2nd- CATALOG and it lists all the commands
you can give your calculator in alphabetical order. Alright the
"->" I have used above is really a sideways arrow
which you get when you push the STO-> button (right above ON).
Str1 is found by VARS-7-ENTER. This means String 1 as I mentioned
above. A string is a variable (like those X's and Y's you always
have to solve for in Algebra) but it is usually a word. It just
consists of more than 1 letter which are put in quotation marks
to indicate they all go together. I used "SPAM SPAM SPAM"
for a few reasons. I could have just used "SPAM" but
then it would have only printed it once on the screen and I wanted
to take up the whole screen. Since I know that a screen is 16
accross and 8 down I figured out that I needed 3 SPAM's with 2
spaces between each one or 4 SPAM's without spaces to equal 16.
When I am referring to 16 that is 16 letters or numbers you can
fit. That isn't important just yet though. Aligning text so it
is centered and all that jazz isn't very important until later.
Next I labeled a point in my code point 1 (Lbl is found at PRGM-9).
I did this so that when I want I can start my code over from right
here and not at the beginning (Not that there is much difference
between the beginning and here but it is redundant to reset Spam
as String 1). (The compiler runs code from top to bottom following
the laws of loops etc.). Alright now I have used ClrHome (PRGM-scroll
to I/O-8). Usually programs start and end with ClrHome because
it does just that...clears the home screen. That way you don't
have to look at all those ugly numbers in the background. In this
program it wasn't really neccessary to clear everything because
we wrote over it directly with Display anyways. Now I set it up
so A=1. I did this because of a lack of a better method to count
anything. What this is going to do since it is located just below
the label 1 is every time my code goes to lable 1 A will reset
at 1 and also the screen will be cleared. Now I've labeled a second
part of my code as Point 2. I did this so I can loop back here
without clearing home and resetting A. Now I used Disp Str1. Disp
is found by hitting PRGM-scrolling to I/O-3. Usually I would type
Disp "Hello World" which would display the text Hello
World. Also if we typed Disp "Hello","World"
seperated by a comma like that each in its own parenthesis then
it would display "Hello" on one line and "World"
on the next. Now that you know how to use the Disp you can almost
make your own Hick Quest. Next is A+1->A. What this does is
increase A by one (the old A plus 1 equals the new A). For this
program if A=1 then I've Displayed spam on one line. If it equals
2 then I've displayed SPAM on 2 lines. So A=The number of lines
I've displayed SPAM on. Now If A=8 (notice I had to use an equal
sign and NOT a -> to test if it is true...because I really
don't know if it is or not. = tests if something is true and ->
makes it true). If is found at Prgm-1. OK what this means is If
SPAM has been displayed on 8 lines (since there aren't any more
than that anyways) then go back up to Lbl 1 and start running
the code from there. It only goes to Lbl 1 if the If statement
is true. So if A doesn't equal 8 then it doesn't go to Lbl 1 either.
Goto is PRGM-0. Next if A<8 (i.e. SPAM hasn't yet covered all
8 lines) then goto l. So basically this program says:
SPAM
=String 1
1=A
Display String 1 (SPAM) 8 times and then clear the screen, display
it 8 more
When
you run this (exit from code window) PRGM then select the screen
saver program from the list and hit ENTER ENTER. You will see
that it seems to move or something because of the strange way
it lights up. That is due to the fact that I don't have all of
the spams displayed at once and that it clears the screen after
each time.
I
actually edited this program specifically for this tutorial. Before
when I had written it up I did a lot more work. It looked like
this I believe.
:ClrHome
:Lbl 1
:Disp "SPAM SPAM SPAM"
:Disp "SPAM SPAM SPAM"
:Disp "SPAM SPAM SPAM"
:Disp "SPAM SPAM SPAM"
:Disp "SPAM SPAM SPAM"
:Disp "SPAM SPAM SPAM"
:Disp "SPAM SPAM SPAM"
:Disp "SPAM SPAM SPAM"
:ClrHome
:Goto 1 |
You
should realize that they do the exact same thing but that the
first one took me around 2 minutes to type up and this one took
me nearly 15 minutes of study hall. I want you to know that there
is always more than one way to do things (in fact I could have
used commans after the first 3 spams and set it up with only 1
Display and 8 sets of 3 SPAM) and if you find something that works
better than what I have put down then most definately use it.
Also notice that you can edit the SPAM text to say something else
like I AM THE COOLEST over and over again. In this instance it
is alot easier to edit the one line of text in the first one than
it is to edit the 8 lines in the second one. To exit this program
click 2nd-On. You will be offered Two choices. The first is Quit
which does just that and the second is Goto which searches to
the point in your code where the compiler had problems reading
it. If you have an error in your code (if you had put Disp "SPAM)
and you had left out the closing parenthesis when you ran your
program it would come up with these same 2 choices Quit and Goto.
You should chose goto and it will send you right to the missing
".
And
That Folks is a Screen Saver (more or less)!
The
Next program I'm going to type up is a password protection program.
I just know all of you paranoia types will love this one. This
is by no means perfect security and can be bypassed but this may
keep your algebra teacher from finding all of your hidden formulas.
The basic idea of a password protection program is that only someone
who supplies the correct User Name and Password may use any given
computer, or in this case calculator. Usually with computer systems
it is shown like this and I will set it up so it uses the same
format. For my password prog the user has to supply the user name
THEN the password, not both at the same time.
Login:
Password:
Alright
here is the source code so set up a new program called PASSWORD
and lets go.
PASSWORD
:ClrHome
:"LOGIN"->Str1
:"PASS"->Str2
:Lbl 1
:Input "LOGIN:",Str3
:If Str3!=Str1
:Goto 1
:Input "PASSWORD:",Str4
:If Str4=Str2
:Disp "WELCOME ABOARD","HACKER"
:If Str4!=Str2
:Goto 1
:Pause
:ClrHome |
I
talked about this earlier
Stores the word login as Str1
Stores the word pass as Str2
Labels as point 1
User's input is saved as Str3
If user's input isn't LOGIN
ask em again
stores user input in Str4
just
says hi
If user's input isn't PASS
start over by asking Login
waits for user to hit enter before exiting
clears the screen and you are ready for math
|
Input
is found under PRGM-scroll to I/O-1. != is really the not equal
to sign (equal sign with a slash through it) which you will find
under TEST. On a computer there isn't a not equals sign so I had
to make do. The syntax of Input works as follows. After the word
input there is the question which is in parenthesis. Up until
this point input is acting just like the Disp command. This is
where it is different. Right after the text in quotation marks
there is a comma then a variable. In my case the variable is a
string, because I expect that they will enter more than a single
letter. If they only enter a single letter or numbers there isn't
really a problem either. The code should be pretty self explanatory.
It starts by saving the Login Name in String 1 and the Password
in String 2. Then it sets up a point which it can loop back to
and it tests to see if the user has correctly guessed the login
name and password. Change these to fit what you like. I use numbers
for mine because they are easier to type quickly. At the end I
put pause. This just holds leaves the displayed information "WELCOME
ABOARD HACKER" on the screen until the user hits ENTER. The
flaws I talked about in this program are of course that the user
can inter something bogus like TAN or LOG buttons and it will
send an error or they could use the 2nd-OFF technique mentioned
above whats more they could hit 2nd-QUIT-CLEAR and they are homefree
too. Since I don't know enough about the getkey function I can't
disable all of these yet. So this of course isn't a perfect program
but its not that bad with what we've got. I use it as a game and
have my friends try to guess my password and login name.
And
that Folks is a Password Protection Prog!
There
is certainly more than these two programs in the realm of calculator
programming but I'm pretty worn out after typing all of this.
I will post a 2nd issue and a 3rd also if I have time. Before
I am all finished though I would like to show you a small DRAW
tutorial.
How
many of you have sat around in algebra trying to draw houses and
smily faces on your calculator using that draw function? How many
have tried to shade in the whole screen? Well there are easier
ways my friends. I'm going to introduce you to some aspects of
DRAW (2nd-PRGM).
When
you go here...
| You'll
See This 1.
ClrDraw
2. Line(
3. Horizontal
4. Vertical
5. Tangent(
6. DrawF
7. Shade(
8. DrawInv
9. Circle(
0. Text(
A. Pen |
They
Do This Clears
the Drawing surface (like ClrHome for math)
Draws a line. Syntax is Line(X1,Y1,X2,Y2)
Draws a line. Syntax is Horizontal Y
Draws a line. Syntax is Vertical X
Dunno but it can be used same as Horizontal
Dunno but it can be used same as Horizontal
Shades screen. Syntax is Shade (-X,X,-Y,Y)
Dunno but it can be used same as Vertical
Draws a circle. Syntax Circle (X,Y,R)
Displays text on Draw surface. Text (X,Y,"TEXT")
You get to draw free hand like in Paint on Windows |
Here
are some footnotes...the notes correspond to the number:
2.
X1,Y1,X2,Y2 symbolizes Two points. point 1(X1,Y2) and point 2(X2,Y2).
The line connects em.
3.
Y=Y intercept (Parrallel to X axis)
4.
X=X interecept (Parrallel to Y axis)
7.
-X,X,-Y,Y symbolizes (Xmin,Xmax,Ymin,Ymax) used the same as when
setting a window. i.e. Shade(-10,10,-10,10) shades the whole screen
9.
X,Y is the origin and R is the radius
0.
X,Y is where the text starts
Now
click 2nd-DRAW-scroll to POINTS. You will be greeted with a list
of options dealing with points and pixels (pxl). Pt-On( and Pxl-On(
do basically the same thing except one is a point and one is a
pixel. A point is what you use when you graph lines etc. A pixel
is those little itsy bitsy squares you can see on your calculator.
When a pixel is on there is a black spot in that square. When
it is off it is "blank". Pt-Change( and Pxl-Change(
change the state of a point or pixel respectively. If a pt/pxl
is on at the given coordinates it turns it off and visa versa.
Pxl-Test( tests to see if a given pixel is on. If the pixel is
on it returns 1 to the main math screen. If it is off it returns
a 0. All of these Pts and Pxls use the same sytnax pt-on(X,Y)
pt-on(X coordinate, Y coordinate). If you draw something really
cool you can go over to the 3rd column in Draw and chose storepic
and give it a name(I think it only accepts numbers). Whenever
you want to see it again just go back to draw and click recallpic
with its name. Good luck and have fun.
