Re: Live Tutoria?
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 21, 2006
- 559 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