Re: typecasts again

new topic     » goto parent     » topic index » view thread      » older message » newer message

Kat wrote:

> This line:
>
> while sequence(TheWebPage[junk][1]) and match(" ",TheWebPage[junk][1])
> do
>
> errors out with :
>
> attempt to subscript an atom
> (reading from it)
>
> Since TheWebPage[junk] is a sequence,
> TheWebPage[junk][1] is a sequence, where is it an atom??

If by some error, the element at TheWebPage[junk] is an atom and not a
sequence, attempting to further index it with the [1] would cause the error
you're getting.

Try:

  while
    sequence(TheWebPage[junk]) and
    sequence(TheWebPage[junk][1]) and
    match(" ",TheWebPage[junk][1])
  do
    -- etc.
  end while

Then again, I'm not sure whether 'while' short-circuits like 'if' does. I
know that return expressions in types and functions don't (In Eu2.3). So,
this would still fail if there's no short-circuiting on the 'while'
condition.

A messy, guaranteed to short-circuit and work as expected workaround is:

  while 1 do if
    sequence(TheWebPage[junk]) and
    sequence(TheWebPage[junk][1]) and
    match(" ",TheWebPage[junk][1])
  then else exit end if
    -- etc.
  end while

HTH,
Carl

--
[ Carl R White == aka () = The Domain of Cyrek = ]
[ Cyrek the Illogical /\ www.cyreksoft.yorks.com ]

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu