to Brent (Lesson 2)
>>>>>
by the way the variable would be
myname=3Dbrent
mycountry=3Dnew zealand
<<<<<
What a great way to start. First, we must know what ASCII is. ASCII is =
a
fancy acronym for all the characters in the "standard" character set. =
Every character has an ascii value. You may know that there are 8 bits i=
n
a byte, and 2^8 =3D 256. That's why there are 256 ASCII characters, from=
0
to 255.
a has value 97, A has value 65 I think. Every character has an ASCII val=
ue
from 0 to 255. The space bar is 32.
Remember how I said Euphoria has two types -- atoms and sequences? Well,=
some languages have strings. Strings are lines of characters.
To Euphoria, there are zero strings. Strings are sequences of ASCII
values.
myname =3D abc
would be the Euphoria sequence {97,98.99} because those are the
corresponding ASCII values. To Euphoria, there is no different between a=
string and a sequence. A string is a sequence of ASCII numbers.
Here's the catch. If you want to enter:
myname=3Dbrent
do you want to enter
myname =3D {asciiB,asciiR...}
I don't think so. So, you have to surround these "strings" with qquotes.=
myname =3D "Brent"
mycountry =3D "New Zealand"
And now you're going to try your first program.
--first.ex--
sequence myname,mycountry
myname =3D "Brent"
mycountry =3D "New Zealand"
puts(1,myname) -- 1 is a i/o designator for standard output, which usuall=
y
-- is the screen
puts(1,mycountry)
--end
What happened? It didn't jump to the next line! The output is smushed
together. You need to output a new line character.
For homework, look for 2.1 of refman.doc and see if you can find how to
output a new-line character. You don't need to output your name and new
line using one statement. Just see if you can, using puts, output a new
line character.
--constants.ex
--let's see what constants are
--you don't need to tell Euphoria what "type"
--a constant is. Just set the value and it will figure it out.
constant myname =3D "brent"
constant mycountry =3D "New Zealand"
puts(1,myname)
puts(1,mycountry)
--end
The point is, you can define constants. The type depends on what you put=
in. I wrote a lot, that's it for now.
--Alan
=
|
Not Categorized, Please Help
|
|