1. typecasts again

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

Kat

new topic     » topic index » view message » categorize

2. Re: typecasts again

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

3. Re: typecasts again

> > 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??
> > >
> > > Kat
> >

Kat,
what do you get if you code it this way instead...

 while 1 do
    if not sequence(TheWebPage[junk][1]) then
        puts(1, "Not a sequence\n")
        exit
    end if
    if not match(" ",TheWebPage[junk][1]) then
        exit
    end if
 . . .
 end while

However, I take it that 'TheWebPage[junk]' is supposed to contain a line of
text. If that is so, then I would expect that 'TheWebPage[junk][1]' would
contain an atom - namely the first character in the line.

----------------
cheers,
Derek Parnell

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

4. Re: typecasts again

Kat:

  Don't forget EOF ( end of file ) is an atom.

Bernie

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

5. Re: typecasts again

On 11 Jan 2003, at 8:13, Derek Parnell wrote:

> 
> > > 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??
> > > >
> > > > Kat
> > >
> 
> Kat,
> what do you get if you code it this way instead...

I recoded the whole block already. 

>  while 1 do
>     if not sequence(TheWebPage[junk][1]) then
>         puts(1, "Not a sequence\n")
>         exit
>     end if
>     if not match(" ",TheWebPage[junk][1]) then
>         exit
>     end if
>  . . .
>  end while
> 
> However, I take it that 'TheWebPage[junk]' is supposed to contain a line of
> text. If that is so, then I would expect that 'TheWebPage[junk][1]' would
> contain an atom - namely the first character in the line.

That stands to reason, however, when i "if sequence()" on it (and it passes), 
then "length()" on it (and it passes), and then it crashes when i attempt to 
use match() on it, and returns that match needs a sequence, or i am 
attempting to read from the atom, it's wasting my time. I want to know if 
there is a " " or ' ' or 32 anywhere there, regardless of it's type. I know i 
assigned a sequence to it, because the only atoms i declared are used as 
integers.

Kat

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

6. Re: typecasts again

On 10 Jan 2003, at 18:21, Bernie Ryan wrote:

> 
> 
> Kat:
> 
>   Don't forget EOF ( end of file ) is an atom.

I didn't forget it, i am not reading a disk file. It's not so much that -1 is
the
EOF, it's an error from trying to read past the end of the file, which *could*
be
a ctrl-z, but may not be. And, this is occuring, afaik, in the middle of the 
data, not the end.

Kat

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

Search



Quick Links

User menu

Not signed in.

Misc Menu