1. If/then and sequences...

Heya all!

Alright, i've got a slight problem...

I've got a sequence. An object even. its called buffer.

I've got to compare a object against another sequence (if buffer[1] =
"//ammo" then ...)

However, when I go and run it, it pukes like so:

"true/false condition must be an ATOM".

Obviously my object i'm comparing against is a sequence, and the
object i'm using is definatly not a sequence.

So, how would I get around this?

TIA,

Blessed Be! --"LEVIATHAN"

new topic     » topic index » view message » categorize

2. Re: If/then and sequences...

On Mon, 28 Aug 2000, you wrote:
> Heya all!
>
> Alright, i've got a slight problem...
>
> I've got a sequence. An object even. its called buffer.
>
> I've got to compare a object against another sequence (if buffer[1] =
> "//ammo" then ...)
>
> However, when I go and run it, it pukes like so:
>
> "true/false condition must be an ATOM".
>
> Obviously my object i'm comparing against is a sequence, and the
> object i'm using is definatly not a sequence.
>
> So, how would I get around this?
>
> TIA,
>
> Blessed Be! --"LEVIATHAN"
Use equal:
if equal(buffer[1], "//ammo") then...

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

3. Re: If/then and sequences...

Use:
if equal( buffer[1], "//ammo" ) then
...

Matt Lewis

> -----Original Message-----
> From: Euphoria Programming for MS-DOS
> [mailto:EUPHORIA at LISTSERV.MUOHIO.EDU]On Behalf Of LEVIATHAN
> Sent: Monday, August 28, 2000 9:34 AM
> To: EUPHORIA at LISTSERV.MUOHIO.EDU
> Subject: If/then and sequences...
>
>
> Heya all!
>
> Alright, i've got a slight problem...
>
> I've got a sequence. An object even. its called buffer.
>
> I've got to compare a object against another sequence (if buffer[1] =
> "//ammo" then ...)
>
> However, when I go and run it, it pukes like so:
>
> "true/false condition must be an ATOM".
>
> Obviously my object i'm comparing against is a sequence, and the
> object i'm using is definatly not a sequence.
>
> So, how would I get around this?
>
> TIA,
>
> Blessed Be! --"LEVIATHAN"
>

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

4. Re: If/then and sequences...

On Mon, 28 Aug 2000 09:33:40 -0700, LEVIATHAN <leviathan at USWEST.NET> wrote:

>Heya all!
>
>Alright, i've got a slight problem...
>
>I've got a sequence. An object even. its called buffer.
>
>I've got to compare a object against another sequence (if buffer[1] =
>"//ammo" then ...)
>
>However, when I go and run it, it pukes like so:
>
>"true/false condition must be an ATOM".
>
>Obviously my object i'm comparing against is a sequence, and the
>object i'm using is definatly not a sequence.
>
>So, how would I get around this?
>
>TIA,
>
>Blessed Be! --"LEVIATHAN"

What does buffer[1] contain ? The error is telling you that
buffer[1] is a atom and NOT a sequence. You are trying to compare
a ATOM with a SEQUENCE. Try printing buffer[1] and you will see
an atom.

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

5. Re: If/then and sequences...

w00t!

equal(s,x) most definatly worked! :)

Now the trick is, to fix what I accidently screwed up :) (No, its
supposed to be *[?] = buffer[2] NOT buffer[3]. Stupid.

Don't worry. Its me talking to myself :)

Buffer never becomes a sequence of atoms. On the contrary, after
putting parse() thru it (strtok.e), it becomes a bunch of sequences.

And then it gets cleared before beginning of while/do loop.

Whee!

Thanx all!

Blessed Be! --"LEVIATHAN"

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

6. Re: If/then and sequences...

On 28 Aug 2000, at 9:33, LEVIATHAN wrote:

> Heya all!
>
> Alright, i've got a slight problem...
>
> I've got a sequence. An object even. its called buffer.
>
> I've got to compare a object against another sequence (if buffer[1] =
> "//ammo" then ...)
>
> However, when I go and run it, it pukes like so:
>
> "true/false condition must be an ATOM".
>
> Obviously my object i'm comparing against is a sequence, and the
> object i'm using is definatly not a sequence.
>
> So, how would I get around this?

>From the Eu refman:

equal
Syntax: i = equal(x1, x2)
Description: Compare two Euphoria objects to see if they are the same. Return 1
(true)
if they are the same. Return 0 (false) if they are different.
Comments: This is equivalent to the expression: compare(x1, x2) = 0
Example 1:
 if equal(PI, 3.14) then
    puts(1, "give me a better value for PI!\n")
end if

Kat

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

7. Re: If/then and sequences...

I just had a similar problem, so here's a variation on the previous
solutions:

if your sequence has or might have more than one item in it, and you want to
test for something specific there, you can use:

    if find(1,KeyPressed) then -- pressed <esc> key ("1")

(where "KeyPressed" is a sequence (using keyread.e) which may contain
scancodes of multiple simultaneous keypresses).

'course, now that I've said that, I've just realized (from reading the
manual!), that that only works if the FIRST item in the sequence is the
match (because it returns the *position* of the match, which is taken as
"true" by the "if" when it is the first position), so I have to go back &
fix that!  But it's potentially useful anyway.

Dan Moyer


----- Original Message -----
From: "LEVIATHAN" <leviathan at USWEST.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Monday, August 28, 2000 9:33 AM
Subject: If/then and sequences...


> Heya all!
>
> Alright, i've got a slight problem...
>
> I've got a sequence. An object even. its called buffer.
>
> I've got to compare a object against another sequence (if buffer[1] =
> "file://ammo" then ...)
>
> However, when I go and run it, it pukes like so:
>
> "true/false condition must be an ATOM".
>
> Obviously my object i'm comparing against is a sequence, and the
> object i'm using is definatly not a sequence.
>
> So, how would I get around this?
>
> TIA,
>
> --"LEVIATHAN"

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

8. Re: If/then and sequences...

Hello Dan,

>     if find(1,KeyPressed) then -- pressed <esc> key ("1")

I do this all the time.

>'course, now that I've said that, I've just realized (from reading the
>manual!), that that only works if the FIRST item in the sequence is the
>match (because it returns the *position* of the match, which is taken as
>"true" by the "if" when it is the first position), so I have to go back &
>fix that!

Any NON-ZERO value will be interpreted as TRUE so it still
works. 0 is false (it didn't "find" it) and anything else
is true and it tells you where.

I do this quite often:

i = find (x, s)
if i then
  do_something (s[i])
end if

>But it's potentially useful anyway.

absolutely.

later,
Lewis Townsend
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

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

9. Re: If/then and sequences...

Lewis,

I forgot that any NON-ZERO value will be interpreted as TRUE .  That does
make it easier, thanks.

And your:
> i = find (x, s)
> if i then
>   do_something (s[i])
> end if

looks like it should be an answer in a EuFAQ.

Dan


----- Original Message -----
From: "Lewis Townsend" <keroltarr at HOTMAIL.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Tuesday, August 29, 2000 5:25 PM
Subject: Re: If/then and sequences...


> Hello Dan,
>
> >     if find(1,KeyPressed) then -- pressed <esc> key ("1")
>
> I do this all the time.
>
> >'course, now that I've said that, I've just realized (from reading the
> >manual!), that that only works if the FIRST item in the sequence is the
> >match (because it returns the *position* of the match, which is taken as
> >"true" by the "if" when it is the first position), so I have to go back &
> >fix that!
>
> Any NON-ZERO value will be interpreted as TRUE so it still
> works. 0 is false (it didn't "find" it) and anything else
> is true and it tells you where.
>
> I do this quite often:
>
> i = find (x, s)
> if i then
>   do_something (s[i])
> end if
>
> >But it's potentially useful anyway.
>
> absolutely.
>
> later,
> Lewis Townsend
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu