Re: Live Tutoria?

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

Lynn Kilroy wrote:
> 
> Okies.  You guys all gave me great advice, so I think I will ask for little=
> 
> code snippets to make mine own include file.  I can examine your snippets t=
> o
> better understand the syntax of the language, and I can ask questions about=
> 
> various snippets.  I know you all already told me about the Inkey Function,=
> 
> but some idiot I've never met decided it was a good idea to delete those=
> 
> messages without putting the code you guys all slaved over and over again o=
> n
> before she could copy it to Euphoria.  So, I'm going to need it again.
> 
> Along with the little code snippets, I think I will ask questions and stuff=
> 
> about the little snippets so I can understand each one.  I will, as I learn=
> 
> the syntax of the language, take cracks at code snippets myself, and post=
> 
> them here to see if I'm beginning to get the hang of things.  I write in=
> 
> QBasic, which isn't case sensative, so this case sensativity thing is new t=
> o
> me.  That said, I was told I have very Pascal conventions in coding, and=
> 
> that I *do* use Caps consistently.
> 
> If I lost anyone, please let me know. {Blushes}
> 
> So, if we may, I would like to begin with the Inkey function.  INKEY$ just=
> 
> reads a key from the keyboard buffer.  It does not wait for a user to press=
> 
> a key. 


-----------------------------------------------------------------
  I'm confused here, how could any keys be in the keyboard buffer if no keys
have been pressed?

-----------------------------------------------------------------
 >Since all my programs use this funtion, and since I'm used to using=
> 
> it, I would like to begin by building a whole new library with this.  I
> guess I would call the file 'Inkey.E,' and and it would be dedicated to all=
> 

I would suggest inkey.e although Inkey.E would problely work. I'm not sure 
about the capital E.
> the functions that read a key from the keyboard buffer.  I will later take=
> 
> cracks at keyboard filter input subroutines, but I think I would include=
> 
> that in my ColorLocate include file {'ClrLcate.E?'}.  If there is nothing i=
> n
> the keyboard buffer, INKEY$ returns a nul string {""}, but I would need to=
> 
   Again why would you care what's in the keyboard buffer if no key has been
 pressed.
   If you are just looking for a place to temparly store stuff use the variable
 temp.
 object temp
or
sequence temp
or
atom temp

depending on what you are expecting to be in temp.

Another way would be to use acquire. (forget that for now)


> know the Euphoria equivilant of this.  You already told me, but I am clearl=
> y
> too lazy to look in the archives.
> 
> So ... to begin with, how would the Include File be formatted?  And how
> would the call be made?  There would be no need to pass an argument to
> function Inkey, as it only returns results: A key from the keyboard buffer.=
> 
> 

> 
> 


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-----------


-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 A Bug is an un-documented feature. A Feature is a documented Bug. }}}

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

Search



Quick Links

User menu

Not signed in.

Misc Menu