[DUG] Is it a bug in latest version of Delphi?

Karl Reynolds kreynolds at chocfishsoft.co.nz
Tue Feb 16 15:05:16 NZDT 2010


On Tue, Feb 16, 2010 at 2:50 PM, Kyley Harris <Kyley at harrissoftware.com> wrote:
> interesting
>>    if Longint(Result) = LB_ERR then Error(SListIndexError, Index);
> it would seem that the error is not in delphi at all. Well.. they are simply
> raising the Windows error which say that -1 is the error result for a bad
> index access from windows. if delphi were to ignore this error and you asked
> for the value at index[99] which was out of bounds and you got -1 instead of
> an error I think there would be the same number of complaints from the other
> side.
> Clearly its the windows API that considers -1 invalid.. not delphi.

The API help says:

"The return value is the value associated with the item, or LB_ERR if
an error occurs."

All that says is that if an error occurs, LB_ERR (-1) will be
returned. The reverse, that -1 indicates an error, does not logically
follow. If you want to know whether an error occurred or not,
GetLastError is the way to do it.

Cheers,
Karl



More information about the Delphi mailing list