1. if statement with sequences

thanx for solving my last problem. this works now. but here comes my
next one:

sequence s
s = {"o", 3}

i want to check if there's an o, so i had this

if s[1] = "o" then do whatever

it doesn't work, i tried changing it to

if s[1] = 'o' then do whatever
if s[1] = 111 then do whatever

but it still doesn't work. i always get the error "true/false
condition must be an ATOM".

what to do?

thanx
felix

new topic     » topic index » view message » categorize

2. Re: if statement with sequences

On 1 Feb 2001, at 9:45, felix geiger wrote:

> thanx for solving my last problem. this works now. but here comes my
> next one:
> 
> sequence s
> s = {"o", 3}
> 
> i want to check if there's an o, so i had this
> 
> if s[1] = "o" then do whatever
> 
> it doesn't work, i tried changing it to
> 
> if s[1] = 'o' then do whatever
> if s[1] = 111 then do whatever
> 
> but it still doesn't work. i always get the error "true/false
> condition must be an ATOM".
> 
> what to do?

Ask Robert to fix this bug? The beauty of an interpreted language is that it is
easier to
provide for exceptions to the existing behavior, and this is a great example. If
the
program syntax is a comparison, return a atomic byte value. Simple, no? I said
byte
value because it's an atom, and Pascal allowed for "fuzzy" true/false values.

Kat

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

3. Re: if statement with sequences

when comparing sequences, use compare() or equal().

- Colin Taylor

----- Original Message ----- 
From: felix geiger <felix.geiger at GMX.CH>

> if s[1] = "o" then do whatever
> 
> it doesn't work

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

4. Re: if statement with sequences

> > sequence s
> > s = {"o", 3}
> >
> > i want to check if there's an o, so i had this
> >
> > if s[1] = "o" then do whatever
> >
> > it doesn't work, i tried changing it to
> >
> > if s[1] = 'o' then do whatever
> > if s[1] = 111 then do whatever

    sequence s

-- your case:

    s = {"o", 3}

    if compare(s[1],"o") then   -- note: "0" is a sequence,
        ? s[1]                  -- so is s[1]. look at compare().
    else
        ? "not eaual!"
    end if

--  but note the following case:

    s = {'o', 3}                -- 'o' an integer which
                                -- represents char. 'o'
    if s[1] = 'o'  then
        ? s[1]
    else
        ? "not eaual!"
    end if

Have a nice day, Rolf

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

Search



Quick Links

User menu

Not signed in.

Misc Menu