RE: Display Text On Screen
"My Name is Sam" is a character string.
It's also a sequence.
{"My Name is Sam"} is not a character string. It is a sequence which
contains a character string.
"A" is a sequence.
{65} is identical to "A"
'A' is an atom
65 is identical to 'A'
print() will display any EU object using code structure.
EG. print(1,"ABC") displays {65,66,67}
puts() will display any 1 dimensional sequence (character string) as
text.
EG. puts(1,"ABC") displays "ABC"
A sequence is defined with enclosing curly braces, or double quotes
In simple terms, a sequence is an array. It can contain any Eu object,
including other sequences.
For example, a character string is a sequence (or array) of bytes, where
each byte represents an ASCII character.
It mainly depends on how your program interperets the sequence though.
{65,66,67,68,69,70} may be a character string ("ABCDEF"), or it might
just be an array of numbers.
Chris
Sam wrote:
> Thanks, miste, jbrow, and Ken Rhodes for your answers to my question
> about single quotes.
>
> I've found three ways to display text on screen.
>
> sequence Me
> Me = "My name is Sam"
> print (1, Me)
>
> Output: {77,121,32,78,97,109,101,32,73,115,32,83,97,109}
>
> Change last line to puts (1, Me)
> Output: My name is Sam
>
> Change last line to printf (1, "%s", Me)
> Output: M
>
> Change program slightly.
> sequence Me
> Me = {"My name is Sam"}
> print (1, Me)
>
> Output: {{77,121,32,78,97,109,101,32,73,115,32,83,97,109}}
> (Dbl. brackets.)
>
> Change last line to puts (1, Me)
> Output (Err msg, sequence found inside character string)
>
> Change last line to printf (1, "%s", Me)
> Output: My name is Sam
>
> O. K., the curly brackets apparently have the effect of making the
> variable definition one unit, rather than a series of separate units.
> Guess I don't really have a question, just an observation that the err
> msg, `sequence found inside character string,' is really not very
> helpful. There's nothing wrong with the sequence, the error is
> (apparently) using puts in an inappropriate way.
>
> Don't misunderstand, I'm not dising Euphoria, just sharing my first
> impressions with you.
>
> Sam
>
>
|
Not Categorized, Please Help
|
|