1. Live Tutoria?
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 19, 2006
- 524 views
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. 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= 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= 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.= >function Inkey >? >end function Please help me with the syntax and stuff for the Inkey.E include file. {Smiles} Love & Friendship & Blessed Be! Lynn Erika Kilroy
2. Re: Live Tutoria?
- Posted by D. Newhall <derek_newhall at yahoo.com> Jan 19, 2006
- 514 views
Lynn Kilroy wrote: > > 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.= > > > >function Inkey > >? > >end function Well, the get_key() routine does the exact same thing as Inkey$ (most BASIC routines have Euphoria equivalents). If you have a file and you want to have stuff that's declared in it exported to other programs you just need to preceed the declaration with "global". So for Inkey() it would be: -- [Declared in file Inkey.e] global function Inkey() return get_key() end function then in some other code after you include the file and you can use Inkey() freely. include Inkey.e integer char char = 0 -- Print the pressed key until Q is hit while char != 'q' do char = Inkey() ? char end while The Euphoria Standard Library project : http://esl.sourceforge.net/ The Euphoria Standard Library mailing list : https://lists.sourceforge.net/lists/listinfo/esl-discussion
3. Re: Live Tutoria?
- Posted by don cole <doncole at pacbell.net> Jan 19, 2006
- 521 views
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. }}}
4. Re: Live Tutoria?
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 20, 2006
- 522 views
Thank you. I will copy the code, and play with it, although there's not= much to play with. Ummm ... My standard exit key is Escape. How would I= identify this in Euphoria? In QBasic, it was as CHR$(27). In Euphoria,= would it be simply 27? >include Inkey.e > >integer char >char = 0 > >-- Print the pressed key until Q is hit >while char != 27 do > char = Inkey() > ? char >end while Another question would be how are arrow keys read? My first program in Euphoria would use the arrow keys. Thank you so very much, and I am grateful for your patience. Love & Friensdship & Blessed Be, Lynn Erika Kilroy >From: "D. Newhall" <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Live Tutoria? >Date: Thu, 19 Jan 2006 03:45:13 -0800 > > >posted by: D. Newhall <derek_newhall at yahoo.com> > >Lynn Kilroy wrote: > > > > 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.= > > > > > > >function Inkey > > >? > > >end function > >Well, the get_key() routine does the exact same thing as Inkey$ (most BASI= C >routines have Euphoria equivalents). If you have a file and you want to= >have stuff that's declared in it exported to other programs you just need= >to preceed the declaration with "global". So for Inkey() it would be: > >-- [Declared in file Inkey.e] >global function Inkey() > return get_key() >end function > >then in some other code after you include the file and you can use Inkey()= >freely. > >include Inkey.e > >integer char >char = 0 > >-- Print the pressed key until Q is hit >while char != 'q' do > char = Inkey() > ? char >end while > > >The Euphoria Standard Library project : > http://esl.sourceforge.net/ >The Euphoria Standard Library mailing list : > https://lists.sourceforge.net/lists/listinfo/esl-discussion > > > > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
5. Re: Live Tutoria?
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 20, 2006
- 508 views
> >-- [Declared in file Inkey.e] >global function Inkey() > return get_key() >end function > >then in some other code after you include the file and you can use Inkey() >freely. > >include Inkey.e > >integer char >char = 0 > >-- Print the pressed key until Q is hit >while char != 'q' do > char = Inkey() > ? char >end while > > So I can conclude the following: Prekey is used to clear the keyboard buffer. This can probably be a procedure, as it returns nothing of value to the main program. I will take a guess at how it will be coded based on what you have sent me. >global procedure Prekey() >while Inkey()>-1 >wend >end procedure Would this be the accurate way to format this for use in the Inkey.e file? Love & Friendship & Blessed Be! Lynn Erika Kilroy
6. Re: Live Tutoria?
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 20, 2006
- 532 views
>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
7. Re: Live Tutoria?
- Posted by don cole <doncole at pacbell.net> Jan 20, 2006
- 498 views
Lynn Kilroy wrote: > > >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. That's exactly what the program I sent you above does? Run it and press ESC. > 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 I'll work on your error and get back to you. Don Cole A Bug is an un-documented feature. A Feature is a documented Bug.
8. Re: Live Tutoria?
- Posted by don cole <doncole at pacbell.net> Jan 20, 2006
- 500 views
include ..\..\include\Inkey.e Inkey.e ========================= ========================= ============= global function Inkey() return get_key() end function global procedure Prekey() while Inkey() > -1 do end while end procedure ========================= ========================= ============= ------------------------------main program--------------- include Inkey.e integer Key Prekey() while Key != 27 do Key = Inkey() ? Inkey() end while You've kind of got things out of order. You didn't declare Key in your main program. If you want to declare Key in your include file that's ok but it must be global. --include file Inkey.e global integer Key--the first way or -----main program integer Key--the second way Either way will work. Actually it is best not to make things global unless it's absolutely necessary So the second way is best. I hope this is clear. Don Cole A Bug is an un-documented feature. A Feature is a documented Bug.
9. Re: Live Tutoria?
- Posted by Jason Gade <jaygade at yahoo.com> Jan 20, 2006
- 614 views
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.
10. Re: Live Tutoria?
- Posted by don cole <doncole at pacbell.net> Jan 20, 2006
- 505 views
Lynn Kilroy wrote: > > > 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? > O/K I missed part 2 of your question. integer Key Key=0 sequence name name={} Don Cole A Bug is an un-documented feature. A Feature is a documented Bug.
11. Re: Live Tutoria?
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 21, 2006
- 504 views
> >That's exactly what the program I sent you above does? >Run it and press ESC. > > > 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 > >I'll work on your error and get back to you. > If I use your code, then I've learned nothing about how Euphoria works. If= you send me code that I can play with that's simple and allows me to draw= conclusions about how the statements and variables all work together, then = I will learn how the language works. My efforts are to learn to write the code by putting together assorted smaller subroutines {procedures} and then making larger and more complicate= d ones. If a program fails to operate, then we can discuss what it is that= I'm trying to do and how I am trying to go about it so I can see what it is= that I'm doing wrong, so as not to repeat the mistake in the future. I tend to use a standard set of functions and subs {procedures}. It would= be best to recreate clones of these and use them in Euphoria for two reasons. The first is that these subs and functions will more closely resemble what I'm used to using, and the second is that through the process= of creating these subs and functions, I would learn more about Euphoria and= have a better understanding how to use the language. The first function, Inkey(), is written. But I do not know truly if it works yet. It is intended to read a key from the keyboard buffer and retur= n the result to the calling program, and is also intended to be kept in an= include file so I can add it without having to retype it over and over and= over again. The second part, a procedure, is Prekey. It calls Inkey until= Inkey returns nothing {and seems to work}. This is done to clear the keyboard buffer, as it has been my experience this is often necessary. The main program is setup as follows: Include Inkey.e file, with Inkey and= Prekey. Define Key as an integer. The definition goes well. While Key != = 27 do, also executes. Key = Inkey(), then ? Key. At ? Key, it says Variable Key is unassigned. The theory is it will print Key on each pass.= =20=20 This is just a test routine, so I don't care if it messes up the display. = I want to know that this, my first Euphoria program, works right. It isn't.= =20=20 So I will include the program and it's include file again. The Program Learning.Ex: ================== >include ..\..\include\Inkey.e > >integer Key > >Prekey() > > >while Key != 27 do > >Key = Inkey() > >? Inkey() > >end while ================== End Program File Learning.Ex The Include File Inkey.e =============== >global function Inkey() >return get_key() >end function > >global procedure Prekey() >while Inkey() > -1 do >end while >end procedure =============== End Include File Inkey.e The error is: ======== >D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\LEARNING.EX:8 >variable Key has not been assigned a value >--> see ex.err ======== End Error Begin Ex.Err ======== >D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\LEARNING.EX:8 >variable Key has not been assigned a value > > >Global & Local Variables > >D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\LEARNING.EX: > Key = <no value> ======== End Ex.Err Please help me understand what is causing this error and how I can fix this= part of my program. It is a pretty basic program, but one has to start somewhere. {Smiles} Thank you very much! Love & Friendship & Blessed Be! Lynn Erika Kilroy -New Users Make Basic Errors. But to ***REALLY*** screw things up, that= takes an experienced user!
12. Re: Live Tutoria?
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 21, 2006
- 560 views
>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 o= r >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) > >}}} <eucode> >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 ></eucode> {{{ > >Instead of assigning 0 to Key, you could put an initial condition right= >before your loop, as follows: > >}}} <eucode> >Key = Inkey() -- initial status of variable >while Key != 27 do > >Key = Inkey() > >? Inkey() > >end while ></eucode> {{{ Thank you! I reformatted the query and reposted it. But since you've answered the question, I guess we can just ignore the other one. {Giggles}= Or I'm more likely to get more and more replies. {Laughs} So it is a pretty simple concept. 1. Declare the variable. 2. Assign the variable a value. 3. Use the variable. That's a little different from QB. In QB, you define it and it had an default assigned value. I will remember that. I will not put a second statement on the same line, and all my initialization code will always be placed before the first sub {procedure}= or function call. {Smiles} The program returned nothing but -1's all the wa= y up the screen. That's a start. With this information, I cleared up the bug, and I added Waitkey. This completes the Inkey.e Include file. Here is the final program to this point. Begin Learning.Ex =========== include ..\..\include\Inkey.e integer Key Key = 0 Prekey() while Key != 27 do Key = Waitkey() ? Key end while ========== End Learning.Ex Begin Inkey.e ========== global function Inkey() return get_key() end function global procedure Prekey() while Inkey() > -1 do end while end procedure global function Waitkey() integer Key Key = -1 while Key = -1 do Key = Inkey() end while return Key end function ============ End Inkey.e Now on to another subroutine. I want to begin to initialize a Procedure= ColorLocatePrint. This procedure's function is to set the color of my text= , put the cursor at a specified location on the screen, and print a string. = I know Euphoria does not have the string mode, so I believe this will actuall= y make it easier to create and use this procedure. Begin ColorLocatePrintTextOnly {BASIC Version} ========================= ====== SUB ColorLocatePrintTextOnly (FGC AS INTEGER, BGC AS INTEGER, Row AS INTEGER, Col AS INTEGER, Text AS STRING) COLOR FGC, BGC LOCATE Row, Col PRINT Text END SUB ========================= ====== End ColorLocatePrintTextOnly {BASIC Version} I know that the variable types are unavailable in Euphoria, as are the QBASIC statements that are called here. We can work on this is two ways.= =20=20 One, we can create a procedure for each of the three seperate functions,= then create another procedure that calls each one, or we can just create on= e procedure to use all of them. I imagine I could spend days slaving over th= e documents looking for how to do this, but I'm an inherently lazy girl, and= so I simply ask you. Thank you very much. Love & Friendship & Blessed Be! Lynn Erika Kilroy
13. Re: Live Tutoria?
- Posted by Jason Gade <jaygade at yahoo.com> Jan 21, 2006
- 494 views
Lynn Kilroy wrote: > > >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 o= > r > >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) > > > >}}} <eucode> > >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 > ></eucode> {{{ > > > >Instead of assigning 0 to Key, you could put an initial condition right= > > >before your loop, as follows: > > > >}}} <eucode> > >Key = Inkey() -- initial status of variable > >while Key != 27 do > > > >Key = Inkey() > > > >? Inkey() > > > >end while > ></eucode> {{{ > > Thank you! I reformatted the query and reposted it. But since you've > answered the question, I guess we can just ignore the other one. {Giggles}= > > Or I'm more likely to get more and more replies. {Laughs} > > So it is a pretty simple concept. > > 1. Declare the variable. > 2. Assign the variable a value. > 3. Use the variable. > > That's a little different from QB. In QB, you define it and it had an > default assigned value. I will remember that. > > I will not put a second statement on the same line, and all my > initialization code will always be placed before the first sub {procedure}= > > or function call. {Smiles} The program returned nothing but -1's all the wa= > y > up the screen. That's a start. > > With this information, I cleared up the bug, and I added Waitkey. This > completes the Inkey.e Include file. Here is the final program to this > point. > > Begin Learning.Ex > =========== > include ..\..\include\Inkey.e > > integer Key > > Key = 0 > > Prekey() > > while Key != 27 do > > Key = Waitkey() > > ? Key > > end while > ========== > End Learning.Ex > > Begin Inkey.e > ========== > global function Inkey() > return get_key() > end function > > global procedure Prekey() > while Inkey() > -1 do > end while > end procedure > > global function Waitkey() > > integer Key > > Key = -1 > > while Key = -1 do > Key = Inkey() > end while > > return Key > > end function <snip> Try this (tested code):
include get.e include graphics.e procedure ColorLocatePrintTextOnly(integer FGC, integer BGC, integer Row, integer Col, sequence Text) text_color(FGC) bk_color(BGC) position(Row, Col) puts(1, Text) text_color(WHITE) bk_color(BLACK) end procedure object Key clear_screen() ColorLocatePrintTextOnly(RED, BROWN, 12, 34, "Hello, World!") Key = wait_key()
Let me know if you have any more questions. Oh, I don't know if you are using email or the web interface for EUforum. If you are using the web interface, you can put \<eucode\> \</eucode\> around a code snippet to "colorize" it in the forum. I don't know if that will come out right (we need a preview in the webforum, please!) but if not, here it is in english: (less-than-symbol)eucode(greater-than-symbol) --code-- (less-than-symbol)/eucode(greater-than-symbol) -- "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.
14. Re: Live Tutoria?
- Posted by Craig Welch <euphoria at welchaviation.org> Jan 21, 2006
- 502 views
>Okies. You guys all gave me great advice, >so I think I will ask for little >code snippets to make mine own include file. key.ex in euphoria\bin will show you keycodes, as well as how to read from the keyboard. I strongly recommend that you run 'rundemos.exw' shortly after, it's the best learning tool around. And code snippets everywhere. -- Craig
15. Re: Live Tutoria?
- Posted by Jason Gade <jaygade at yahoo.com> Jan 21, 2006
- 514 views
Craig Welch wrote: > 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. > > key.ex in euphoria\bin will show you keycodes, as well as how to read from the > keyboard. > > I strongly recommend that you run 'rundemos.exw' shortly after, it's the best > learning tool around. And code snippets everywhere. > > -- > Craig BTW, rundemos.exw is with win32lib Also, Lynn, with regards to your Inkey program you should use puts() instead of ? or print(). print() and ? print sequences as numbers whereas puts() prints sequences as strings. I won't explain printf() here (read the docs) but it is pretty flexible for printing out different data types. Euphoria doesn't have a built-in procedure like BASIC's PRINT that determines the type of a variable automatically and prints it out accordingly. You have to specifiy it like in C. -- "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.