1. RE: Live Tutoria?

Jason Gade wrote:
> <snip>
> 
> Try this (tested code):
> }}}
<eucode>
> 
> 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()
> </eucode>
{{{

> 
> Let me know if you have any more questions.
>

I moved your procedure in to an include file {successfully, so I'm 
learning some things}.

How do I compose a string with the output of wait_key?  That I know that 
one is also very telling - I integrated it in Inkey.

> 
> 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 am using Topica to view and reply to the forum, now.  Seems that 
something was buggy with my Hotmail interface.  See if Topica will work 
better.

Which means I have a Topica account. {Giggles} I even own several dead 
mailing lists!  Aren't I special? {Laughs}

Love & Friendship & Blessed Be!
Lynn Erika Kilroy

new topic     » topic index » view message » categorize

2. RE: Live Tutoria?

I do have a question.  Inkey outputs an integer, which is good because 
all my filters use the integer values for sorting out the keys.  But 
this is also bad because I try using ColorLocatePrintTextOnly, and 
ColorLocatePrintTextOnly, as in QBasic, expects only a string.  How do I 
fix this?

Love & Friendship & Blessed Be!
Lynn Erika Kilroy

new topic     » goto parent     » topic index » view message » categorize

3. RE: Live Tutoria?

Craig Welch wrote:
> 
> 
> posted by: Craig Welch <euphoria at welchaviation.org>
> 
> 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

I looked through the demos.  I played with them.  And they lost me.  
Teaching stuff often does that.  But then, I have a notoriously odd way 
of thinking.  Mebbe because I'm a girl?

Love & Friendship & Blessed Be!
Lynn Erika Kilroy

new topic     » goto parent     » topic index » view message » categorize

4. RE: Live Tutoria?

Lynn Kilroy wrote:

> How do I compose a string with the output of wait_key?  That I know that 
> one is also very telling - I integrated it in Inkey.

See http://www.rapideuphoria.com/lib_u_z.htm#wait_key

Here is an example:

include get.e

function Input()
    sequence string_in -- a place to store our string
    integer key -- the next key in the buffer

    string_in = {} -- empty sequence/string
    key = wait_key() -- get the first key
    while key != 13 do
        puts(1, key) -- echo the key to the screen
        string_in &= key -- add the key onto the string
        key = wait_key() -- get another key
    end while

    return string_in
end function

sequence new_string
new_string = Input()

puts(1, new_string)


Of course you could just use gets(), see
http://www.rapideuphoria.com/lib_e_g.htm#gets example 2.

> 
> > 
> > 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 am using Topica to view and reply to the forum, now.  Seems that 
> something was buggy with my Hotmail interface.  See if Topica will work 
> better.
> 
> Which means I have a Topica account. {Giggles} I even own several dead 
> mailing lists!  Aren't I special? {Laughs}

Try using the web interface directly to the Forum
http://www.listfilter.com/EUforum it works very well, much better than Topica.

> 
> Love & Friendship & Blessed Be!
> Lynn Erika Kilroy
> 
> 


--
"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 message » categorize

5. RE: Live Tutoria?

Lynn Kilroy wrote:
> 
> I do have a question.  Inkey outputs an integer, which is good because 
> all my filters use the integer values for sorting out the keys.  But 
> this is also bad because I try using ColorLocatePrintTextOnly, and 
> ColorLocatePrintTextOnly, as in QBasic, expects only a string.  How do I 
> fix this?
> 
> Love & Friendship & Blessed Be!
> Lynn Erika Kilroy
> 
> 

In Euphoria, characters are just integers from 0 to 255. Strings are sequences
of characters. The only difference is how you interpret them.

For example, 'A' is the same as the integer 65. You could write an if statement
either way:

if Key = 'A' then puts(1, "It's an A!\n") end if
if Key = 65 then puts (1, "It's still an A!\n") end if


For strings, the sequence {65, 66, 67} is the same as "ABC".

No need for a CHR$() in Euphoria!

--
"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 message » categorize

6. RE: Live Tutoria?

Lynn Kilroy wrote:
> 
> Craig Welch wrote:
> > 
> > 
> > posted by: Craig Welch <euphoria at welchaviation.org>
> > 
> > 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
> 
> I looked through the demos.  I played with them.  And they lost me.  
> Teaching stuff often does that.  But then, I have a notoriously odd way 
> of thinking.  Mebbe because I'm a girl?
> 
> Love & Friendship & Blessed Be!
> Lynn Erika Kilroy
> 
> 

Have you had a chance to look at the Euphoria documentation yet? I think that it
is actually very well written but it might take a couple of times through it to
figure stuff out.

Also, check out the contents of the tutorial directory under your main Euphoria
directory. Those are some very simple examples.

I will keep pointing you to the documentation, but I also don't mind answering
your questions.

--
"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 message » categorize

7. RE: Live Tutoria?

> 
> BTW, rundemos.exw is with win32lib
> 

I saw the extension .exw and gathered as much.  For the time being, I 
will stick with DOS to get a better feel for the program and build my 
basic library. {Smiles}

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

The Inkey program was used to help construct the Inkey procedures, two 
of which {I can quite proudly say} I wrote myself with only a little 
help from you. {Beaming}

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

That makes sense.  It's interesting that you would say this, about the 
output type being specified.  When I originally coded these subroutines, 
I specified the type of variable to be printed.  As a result, each of my 
ColorLocatePrint procedures only print one type of variable.

Ummm ...  It get's better ... {Blushing}

I wanted total control over how things were formatted and printed in 
QBasic.  PRINT and PRINT USING are good, but I wanted ***MORE***.  So my 
ColorLocatePrint subroutines ended up being restricted to Text Only 
printing capabilities {Strings}, for formatting.  The idea {and a great 
deal of the messes I make programming} is that I would format all output 
in to strings, then send those strings to ColorLocatePrint to be 
colored, positioned and printed on the screen.  ColorLocatePrint made my 
screens real purdy.  People were often amazed how well the scripts 
worked.

Love & Friendship & Blessed Be!
Lynn Erika Kilroy

new topic     » goto parent     » topic index » view message » categorize

8. RE: Live Tutoria?

Lynn Kilroy wrote:
> 
> I do have a question.  Inkey outputs an integer, which is good because 
> all my filters use the integer values for sorting out the keys.  But 
> this is also bad because I try using ColorLocatePrintTextOnly, and 
> ColorLocatePrintTextOnly, as in QBasic, expects only a string.  How do I 
> fix this?
> 
> Love & Friendship & Blessed Be!
> Lynn Erika Kilroy
> 
> 
I posted some code explaning that but you said it was all greek to you.

I will try again with further explination.

You wanted to know if Esc was 27 in euphoria like Q Basic this code will

answer that question.

------------------code------------------

---ascii.ex find the ascii code of a keystroke

include get.e
-- the wait_key function is in here
include graphics.e 
--the colors are in here

integer key--declare our only vriable
 
while 1 =1 do--loop to keep doing wait_keys
  text_color(BRIGHT_BLUE)--purty stuff
 puts(1,--prints to the screen(1) text
      "[F1](315)to Exit  ")--the text actually printed
puts(1,"< Hit Any Key >")--note the lack of any "\n"(carriage return or next
 line)
                          --so both puts are printed on the same line

    key = wait_key()--returns an integer
   if key=315 then --if it is asc for F1 then quit program
       exit
   end if
 text_color(WHITE)--more purdy stuff
  printf(1,--print formatted to the screen(1)
"\nprintf sequence=%s",--a carriage return folowed by th text 'printf
         sequence='
--The % means the next letter will not be
                                printed
--%s is a code to tell euphoria the way it will
                                be printed
                                --in this case %s means sequence or string
--the %s will be printed to the screen as a
                                string
          {key})--this is what %s interpets 
                --in this case key as text or string or sequence
                --if the 'f' key was struck then 'f' would be printed
  printf(1,--same as above
"\nprintf decimal=%d\n",--same as above but noice that the %s has been
          changed
--to %d the code to tell euphoia to print as a
                                  decimal
                                  -- note the carriage return "\n" here
{key})         --so if the 'f' key was struck the 102 would be
           printed here.
  printf(1,"ascii=%d\n",{key})
  printf(1,"euphoria expresion=%d\n",{key})
end while


I would like to point out that 
         ?a is the same as printf(1,"%d",a) and
  puts(1,a} is the same as printf(1,"%s",{a})

  You should really study the help file on printf.
  I really like David Gay's tutorial in the archives (witten in dos)
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=gay
   
One more thing the code that Jason Gade sent you, input() will handle long
strings like Qbasic's INPUT whare as my code only handles one chr at a time.

I would  also point out that a string always = sequence but a sequence
does not always = a string.(Again see Gay's tutorial)

I know this might be a bit much but I hope it helps.
I like your idea of sticking with Dos for now. 
That what I did when I first started  w/Euphoria.

Don Cole
 A Bug is an un-documented feature.
A Feature is a documented Bug.

new topic     » goto parent     » topic index » view message » categorize

9. RE: Live Tutoria?

> Here is an example:
> 
> }}}
<eucode>
> include get.e
> 
> function Input()
>     sequence string_in -- a place to store our string
>     integer key -- the next key in the buffer
> 
>     string_in = {} -- empty sequence/string
>     key = wait_key() -- get the first key
>     while key != 13 do
>         puts(1, key) -- echo the key to the screen
>         string_in &= key -- add the key onto the string
>         key = wait_key() -- get another key
>     end while
> 
>     return string_in
> end function
> 
> sequence new_string
> new_string = Input()
> 
> puts(1, new_string)
> </eucode>
{{{

>

Sequence is the Euphoria equivilant of the Array, correct?  And it 
really has no real type, and &= tells Euphoria to place the value of the 
var on the right of the &= in to the next element in the sequence on the 
left, correct?

So I added it with some little tidbits and ended up with a dump.

D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\..\..\include\clrlcte.e:4 in
procedure ColorLocatePrintTextOnly() 
type_check failure, Text is 72'H' 
    FGC = 14
    BGC = 1
    Row = 1
    Col = 1
    Text = 72'H'

... called from D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\LEARNING.EX:21 


Global & Local Variables

 C:\Progra~1\Euphoria\include\get.e:
    input_file = <no value>
    input_string = <no value>
    string_next = <no value>
    ch = <no value>

 C:\Progra~1\Euphoria\include\graphics.e:
    BLUE = 1
    CYAN = 3
    RED = 4
    BROWN = 6
    BRIGHT_BLUE = 9
    BRIGHT_CYAN = 11
    BRIGHT_RED = 12
    YELLOW = 14

 C:\Progra~1\Euphoria\include\misc.e:
    pretty_end_col = <no value>
    pretty_chars = <no value>
    pretty_start_col = <no value>
    pretty_level = <no value>
    pretty_file = <no value>
    pretty_ascii = <no value>
    pretty_indent = <no value>
    pretty_ascii_min = <no value>
    pretty_ascii_max = <no value>
    pretty_line_count = <no value>
    pretty_line_max = <no value>
    pretty_dots = <no value>
    pretty_fp_format = <no value>
    pretty_int_format = <no value>
    pretty_line = <no value>

 D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\LEARNING.EX:
    Text = {72'H'}
    Key = 72'H'


Tell me what I'm doing wrong?

Love & Friendship & Blessed Be!
Lynn Erika Kilroy

> 
> Of course you could just use gets(), see 
> http://www.rapideuphoria.com/lib_e_g.htm#gets example 2.
> 
> 
> Try using the web interface directly to the Forum 
> http://www.listfilter.com/EUforum it works very well, much better than 
> Topica.
> 

I hate random passwords.

Love & Friendship & Blessed Be!
Lynn Erika Kilroy

new topic     » goto parent     » topic index » view message » categorize

10. RE: Live Tutoria?

Jason Gade wrote:
> 
> I will keep pointing you to the documentation, but I also don't mind 
> answering your questions.
> 

The documentation mostly appeared to describe the advantages of 
Euphoria, and that's what really interests me.  Also, I can state in a 
demonstration that SCREEN 13 turn on 320 x 200 x 256 graphics and 40 x 
25 text, and not really be all that informative on how to use SCREEN.  I 
am not a cracker.  I don't really see all the little quirks when there's 
about a billion of them at once, or, in the case of a lot of the demos, 
about six or seven incompletely explained statements with which I'm 
unfamiliar.

Love & Friendship & Blessed Be!
Lynn Erika Kilroy

new topic     » goto parent     » topic index » view message » categorize

11. RE: Live Tutoria?

Lynn Kilroy wrote:
> 
> > Here is an example:
> > 
> > }}}
<eucode>
> > include get.e
> > 
> > function Input()
> >     sequence string_in -- a place to store our string
> >     integer key -- the next key in the buffer
> > 
> >     string_in = {} -- empty sequence/string
> >     key = wait_key() -- get the first key
> >     while key != 13 do
> >         puts(1, key) -- echo the key to the screen
> >         string_in &= key -- add the key onto the string
> >         key = wait_key() -- get another key
> >     end while
> > 
> >     return string_in
> > end function
> > 
> > sequence new_string
> > new_string = Input()
> > 
> > puts(1, new_string)
> > </eucode>
{{{

> >
> 
> Sequence is the Euphoria equivilant of the Array, correct?  And it 
> really has no real type, and &= tells Euphoria to place the value of the 
> var on the right of the &= in to the next element in the sequence on the 
> left, correct?

Yes, that is correct. Like C and other related languages (and like at the
machine level) a string is just an array of characters. When I first started with
8-bit BASICs on the Apple-][ and Commodore-64 I didn't realize this.

Yes, &= "appends" the value to the end of a sequence. I probably shouldn't have
used the shortcut, I probably should have used the long version:
string_in = string_in & Key
Same thing, just a shortcut. Again, a shortcuts like this are a useful relic
from C.

> 
> So I added it with some little tidbits and ended up with a dump.
> 
> }}}
<eucode>
> D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\..\..\include\clrlcte.e:4 in 
> procedure ColorLocatePrintTextOnly() 
> type_check failure, Text is 72'H' 
>     FGC = 14
>     BGC = 1
>     Row = 1
>     Col = 1
>     Text = 72'H'
> 
> ... called from D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\LEARNING.EX:21 
> 
> 
> Global & Local Variables
> 
>  C:\Progra~1\Euphoria\include\get.e:
>     input_file = <no value>
>     input_string = <no value>
>     string_next = <no value>
>     ch = <no value>
> 
>  C:\Progra~1\Euphoria\include\graphics.e:
>     BLUE = 1
>     CYAN = 3
>     RED = 4
>     BROWN = 6
>     BRIGHT_BLUE = 9
>     BRIGHT_CYAN = 11
>     BRIGHT_RED = 12
>     YELLOW = 14
> 
>  C:\Progra~1\Euphoria\include\misc.e:
>     pretty_end_col = <no value>
>     pretty_chars = <no value>
>     pretty_start_col = <no value>
>     pretty_level = <no value>
>     pretty_file = <no value>
>     pretty_ascii = <no value>
>     pretty_indent = <no value>
>     pretty_ascii_min = <no value>
>     pretty_ascii_max = <no value>
>     pretty_line_count = <no value>
>     pretty_line_max = <no value>
>     pretty_dots = <no value>
>     pretty_fp_format = <no value>
>     pretty_int_format = <no value>
>     pretty_line = <no value>
> 
>  D:\LEKSSOFT\EUPHORIA\SOURCE\LEARNING\LEARNING.EX:
>     Text = {72'H'}
>     Key = 72'H'
> </eucode>
{{{

> 
> Tell me what I'm doing wrong?
> 
> Love & Friendship & Blessed Be!
> Lynn Erika Kilroy

It looks like you are passing an integer or an atom where Euphoria expects a
sequence. This is a common problem. Whichever way you are calling
ColorLocatePrintTextOnly(), wrap the Text parameter with {}. That is call it like
so:
ColorLocatePrintTextOnly(FGC, BGC, Row, Col, {Key})

Without more information of what kind of tidbits you are adding, that is all I
can come up with.

You could also change the ColorLocatePrintTextOnly definition to accept an
object for Text instead of a sequence:
procedure ColorLocatePrintTextOnly(integer FGC, integer BGC, integer Row,
integer Col, object Text)

> > 
> > Of course you could just use gets(), see 
> > <a
> > href="http://www.rapideuphoria.com/lib_e_g.htm#gets">http://www.rapideuphoria.com/lib_e_g.htm#gets</a>
> > example 2.
> > 
> > 
> > Try using the web interface directly to the Forum 
> > <a
> > href="http://www.listfilter.com/EUforum">http://www.listfilter.com/EUforum</a> it
> > works very well, much better than
> > Topica.
> > 
> 
> I hate random passwords.

Yeah, but if you use cookies (I know some people don't) then it is saved on your
computer. Really, it is a better way to access the list.

But, whatever works for you.

> 
> Love & Friendship & Blessed Be!
> Lynn Erika Kilroy
> 
> 
--
"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 message » categorize

12. RE: Live Tutoria?

Jason Gade wrote:
> 
> > 
> > Sequence is the Euphoria equivilant of the Array, correct?  And it 
> > really has no real type, and &= tells Euphoria to place the value of the 
> > 
> > var on the right of the &= in to the next element in the sequence on the 
> > 
> > left, correct?
> 
> Yes, that is correct. Like C and other related languages (and like at 
> the machine level) a string is just an array of characters. When I first 
> started with 8-bit BASICs on the Apple-][ and Commodore-64 I didn't 
> realize this.
> 
> Yes, &= "appends" the value to the end of a sequence. I probably 
> shouldn't have used the shortcut, I probably should have used the long 
> version:
> string_in = string_in & Key
> Same thing, just a shortcut. Again, a shortcuts like this are a useful 
> relic from C.
> 

This is okay.  I like it, and it isn't that hard to understand.  I 
learned it from what you showed me and could guess at it's meaning.  How 
do I drop a character off the end of the array/sequence?

> > 
> > So I added it with some little tidbits and ended up with a dump.
> > 
> > }}}
<eucode>
> > {Removed}
> > </eucode>
{{{

> > 
> > Tell me what I'm doing wrong?
> > 
> > Love & Friendship & Blessed Be!
> > Lynn Erika Kilroy
> 
> It looks like you are passing an integer or an atom where Euphoria 
> expects a sequence. This is a common problem. Whichever way you are 
> calling ColorLocatePrintTextOnly(), wrap the Text parameter with {}. 
> That is call it like so:
>

I am such an idiot!  I had integer Key, and sequence Text.  I put 
integer Key where sequence Text belonged, like this:

ColorLocatePrint(14, 1, 1, 1, Key)


instead of like this:

ColorLocatePrint(14, 1, 1, 1, Text)


No wonder I was having such problems!

Love & Friendship & Blessed Be!
Lynn Erika Kilroy

new topic     » goto parent     » topic index » view message » categorize

13. RE: Live Tutoria?

Lynn Kilroy wrote:
> This is okay.  I like it, and it isn't that hard to understand.  I 
> learned it from what you showed me and could guess at it's meaning.  How 
> do I drop a character off the end of the array/sequence?

Like this:
new = old[1..length(old)-1] -- for Euphoria 2.4 and below
--or--
new = old[1..$-1] -- for Euphoria 2.5

The '$' is a shortcut for length() and is very useful. Length still works,
though, so you can still use it if you prefer or if it makes your code more
clear.

You can probably also guess how to remove an element from the beginning. Can you
think of how to take one out of the middle?

--
"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 message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu