RE: getLVSelectedText bug?

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

Thank you Quantum Analyst. Your suggestion (subitem +1) helped. No need to say
that I'm feeling stupid. Of course I know that 'if a >= 0 ' will succeed if a=0.
But it sometimes happens to me that something obvious falls into a kind of mental
blind spot. Hopefully I saw it happen to other more experienced programmers too.
So I don't feel too stupid.

In any case there is a problem with that function. If you look at fucntion
getLVSelectedText you'll see that it calls getLVItemText with the third param
being always 0. Which with the current version of getLVSelectedText will always
cause an error.

What puzzles me is that it worked in the past and I still don''t know why nor
from which version of win32lib the problem appeared.

Henri Goffin



> -----Original Message-----
> From:	quantum_analyst at hotmail.com [SMTP:quantum_analyst at hotmail.com]
> Sent:	samedi 3 novembre 2001 4:23
> To:	EUforum
> Subject:	Re: getLVSelectedText bug?
> 
> 
> Henry,
>     This isn't a bug in the short-circuit. The coding is not right. The part 
> 'subitem >= 0' messes it up. It should be 'subitem > 0' or the 
> 'text=peek...' line should read 
> 'text=peek_string(lvitem_data[item][2][subitem + 1][1]) although the second 
> form might mess up something else. You can't subscript the index 0. Maybe 
> you should ask Derek to fix this up.
> 
> >From: Henri.Goffin at sbs.be
> >Reply-To: EUforum at topica.com
> >To: EUforum <EUforum at topica.com>
> >Subject: getLVSelectedText bug?
> >Date: Fri, 2 Nov 2001 18:13:13 +0100
> >
> >
> >Matt Lewis's ODBC.EXW used to work fine until...
> >
> >Now I get something intriguing:
> >
> >D:\Euphoria\include\win32lib.ew:10813 in function getLVItemText()
> >subscript value 0 is out of bounds, reading from a sequence of length 2
> >     id = 4
> >     item = 5
> >     subitem = 0
> >     text = {}
> >
> >... called from D:\Euphoria\include\win32lib.ew:10930 in function 
> >getLVSelectedText()
> >     id = 4
> >     text = {5}
> >     i = 1
> >
> >I traced the code in getLVItemText() (from win32lib v0.55.4) that goes:
> >
> >     if item > 0 and item <= length(lvitem_data) and
> >        subitem >= 0 and subitem <= length(lvitem_data[item][2]) and
> >        id = lvitem_owner[ item ]
> >     then
> >         text = peek_string(lvitem_data[item][2][subitem][1])
> >     end if
> >
> >and, though subitem is 0, as showed in the ex.err file above, the if-test 
> >goes straight to the 'text=peek...' statement.
> >Is it a badly behaved short-circuit?
> >
> >Henri Goffin
> >
> >
> 
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu