Re: Live Tutoria?

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

>To get one key at a time:
>
>integer a
>sequnce b
>a=wait_key()
>
>
>Read up on getc() and gets()
>
>
>To get a string from the keyboard:
>
>function get_string()
>   sequence words
>   integer a
>    words=""
>    a=wait_key()
>    if a=13 then--Enter
>     return words
>    end if
>    words=words & sprintf("%s",a)
>end function
>
>------------------------run this program-----------
>}}}
<eucode>
>
>---ascii.ex find the ascii code of a keystrpoke
>
>include get.e
>include graphics.e
>
>integer key
>
>while 1 =1 do
>   text_color(BRIGHT_BLUE)
>  puts(1,"[F1](315)to Exit  ")
>  puts(1,"< Hit Any Key >")
>
>     key = wait_key()
>    if key=315 then
>        exit
>    end if
>  text_color(WHITE)
>   printf(1,"\nprintf sequence=%s",{key})
>   printf(1,"\nprintf decimal=%d\n",{key})
>   printf(1,"ascii=%d\n",{key})
>   printf(1,"euphoria expresion=%d\n",{key})
>end while
>
>--------------end of program-------------------
>Don Cole

Ummmm ....  Very helpful ....  But it kind of reminds me of Greek, and is=
=20
about as understandable to me, which means it's of little use to me.  Which=
=20
is why I'm working with little code snippets for the time being.  The idea=
=20
is that sooner or later, I will learn all kinds of neat things that will=
=20
allow me to write more efficient code.  Also, I will build a library of=20
subroutines and functions {okay, for those dedicated to C, ***PROCEDURES***=
=20
and functions} that more conform to my standard libraries that I use.  But,=
=20
since you're planning on being so useful, perhaps you can help me with a=
=20
little bit of code I'm dabbling with?  Just for starters?  Since I can't=
=20
complete an actual program until all subroutines are complete {or at least=
=20
enough to say so} and I understand enough of the Euphoria Statements to be=
=20
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=20
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
=========================
=========================
=============

=20
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

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

Search



Quick Links

User menu

Not signed in.

Misc Menu