"vm" <v...@gte.net> wrote in message news:3b68e052_1@dnews...
Still get class EStringListError with message 'List index out of bounds
(71)'.
--
ô¿ô
V e r n www.parentpresent.org
"Jonas Malmsten" <ne...@malmsten.net> wrote in message
news:3b68e1fc_1@dnews...
>
> function LastIsEmpty(sl: TStringList): Boolean;
> begin
> Result := (sl.Count > 0) and (sl[sl.Count - 1] = '');
> end;
>
> "vm" <v...@gte.net> wrote in message news:3b68e052_1@dnews...
> > How do i safely check to see
> > if the last entry in a TStringList
> > is empty?
> > Thanks!
> > --
> > ô¿ô
either 1) you have switched on complete evaluation in your compiller options
(default is off) or 2) your exception is generated by something else or 3)
I'm having one of those days when I should not write one single line of
code. Also make sure that the tstringlist has been created properly, however
that should not generate the type of error you are receiving.... Post some
more code describing what you are doin'.
/Jonas
"vm" <v...@gte.net> wrote in message news:3b68ea50$1_1@dnews...
>How do i safely check to see
>if the last entry in a TStringList
>is empty?
Before answering that, can you tell me why you want to know this
information? I see from the other answer that you are getting a List
Index out of bounds error. Is that the real problem here? If so, fix
that problem, and don't try to figure out what the last line in your
stringlist is doing.
Nick Hodges - TeamB
HardThink, Inc.
2) // roughly i am doing this:
InLinesCurLinesCnt := 0;
ButtonLines := TStringlist.Create;
ButtonLines.LoadFromFile(OpenedFileName);
............
WHILE InLinesCurLinesCnt <= ButtonLines.count DO
..........
WHILE InLinesCurLinesCnt <= ButtonLines.count DO
// Parse each line from file.
BEGIN
......................
IF InLinesCurLinesCnt = ButtonLines.count THEN // BREAK;
Begin
IF LastIsEmpty(ButtonLines) Then BREAK;
End;
INC(InLinesCurLinesCnt);
.....................
3)
Function TForm1.LastIsEmpty(sl: TStringList): Boolean;
begin
Result := (sl.Count > 0) and (sl[sl.Count - 1] = '');
end;
--
ôżô
Ouch! you should be using < instead of <= as the index goes from 0 to
Count - 1
What you have there will definitely cause the out of bounds exception you
were describing...
--
Paul Nicholls (Delphi 5) Live long and optimise!
"Life is a beach - every so often you are swept out to sea by a rip and get
into trouble!" - Paul Nicholls
Home Page: www.southcom.com.au/~phantom
< IF YOU WANT TO EARN MONEY WHILE YOU SURF ON THE NET GO HERE: >
< http://www.alladvantage.com/go.asp?refid=BEM-274 >
in article <3b68e052_1@dnews>, you wrote:
> How do i safely check to see
> if the last entry in a TStringList
> is empty?
>
if myStringList.Count > 0 then
if myStringList[Pred(myStringList.Count] = '' then
---
Regards
Ralph (TeamB)
***
This should be:
WHILE InLinesCurLinesCnt < ButtonLines.count DO
Mike Orriss (TeamB and DevExpress)
> How do i safely check to see
> if the last entry in a TStringList
> is empty?
if YourList[YourList.Count - 1] = '' then
--
Rudy Velthuis (TeamB)