Re: Live Tutoria?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Lynn Kilroy wrote:

<snip>

> Which=
> 
> is why I'm working with little code snippets for the time being.  The idea=
> 
> is that sooner or later, I will learn all kinds of neat things that will=
> 
> allow me to write more efficient code.  Also, I will build a library of
> subroutines and functions {okay, for those dedicated to C, ***PROCEDURES***=
> 
> and functions} that more conform to my standard libraries that I use.  But,=
> 
> since you're planning on being so useful, perhaps you can help me with a=
> 
> little bit of code I'm dabbling with?  Just for starters?  Since I can't=
> 
> complete an actual program until all subroutines are complete {or at least=
> 
> enough to say so} and I understand enough of the Euphoria Statements to be=
> 
> able to get it to do at least something close to what I want.
> 
> This program is supposed to print keypresses from the keyboard.  But it
> crashes.  "Variable Key has not been assigned a value."  What is the causin=
> g=20
> the error, please?  And how do I assign Key a value?
> 
> Love & Friendship & Blessed Be!
> Lynn Erika Kilroy
> 
> Learning.ex
> =========================
> =========================
> =============
> include ..\..\include\Inkey.e
> 
> integer Key
> 
> Prekey()
> 
> 
> while Key != 27 do
> 
> Key = Inkey()
> 
> ? Inkey()
> 
> end while
> =========================
> =========================
> =============
> 
> Inkey.e
> =========================
> =========================
> =============
> global function Inkey()
> return get_key()
> end function
> 
> global procedure Prekey()
> while Inkey() > -1 do
> end while
> end procedure
> =========================
> =========================
> =============
> 
> 
> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> 
> 
Okay, the line in your program
while Key != 27 do
is the problem. Before that, you have declared Key but not yet assigned it a
value. All variables must be assigned a value before they are compared or added 1
to or whatever.

So before your loop you must say
Key = 0
or
Key = Inkey()

So here is your code (untested, but should work)

include ..\..\include\Inkey.e
 
integer Key
Key = 0 -- could put this on the same line if you wanted to, like this:
-- integer Key Key = 0

 
Prekey()
 

while Key != 27 do
 
Key = Inkey()
 
? Inkey()
 
end while


Instead of assigning 0 to Key, you could put an initial condition right before
your loop, as follows:

Key = Inkey() -- initial status of variable
while Key != 27 do
 
Key = Inkey()
 
? Inkey()
 
end while


--
"The author regrets that he is unable to reconcile himself to the
thoughtful point of view you have expressed. However, it must be kept
in mind that being raised in different cultures and different places can
result in such differences of viewpoint between individuals.
The author is from planet Earth." [author unknown]

j.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu