Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-08

TStringList.indexOf (case-sensitivity)

7 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

James Mills

Hi,

Is TStringList.indexOf case sensitive or insensitive ? TStrings.indexOf is case insensitive, but TStringList.indexOf overrides the TStrings.indexOf implementation accoriding to the documentation.

cheers
James

- -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape.

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 5 lines
Hi, Is TStringList.indexOf case sensitive or insensitive ? TStrings.indexOf is case insensitive, but TStringList.indexOf overrides the TStrings.indexOf implementation accoriding to the documentation.

It is case insensitive, but this was changed recently for Delphi compatibility.
Older versions are case sensitive. Here are the relevant log entries:

revision 1.15
date: 2003/05/29 23:13:57; author: michael; state: Exp; lines: +5 -2 fixed case insensitivity of TStrings.IndexOf
----------------------------
revision 1.14
date: 2002/12/10 21:05:44; author: michael; state: Exp; lines: +12 -5
+ IndexOfName is case insensitive
----------------------------

Michael.

Reply by email

James Mills
to Michael Van Canneyt
Michael Van Canneyt wrote 22 lines
On Wed, 27 Aug 2003, James Mills wrote: > Hi, > > Is TStringList.indexOf case sensitive or insensitive ? > TStrings.indexOf is case insensitive, but TStringList.indexOf overrides > the TStrings.indexOf implementation accoriding to the documentation. It is case insensitive, but this was changed recently for Delphi compatibility. Older versions are case sensitive. Here are the relevant log entries: revision 1.15 date: 2003/05/29 23:13:57; author: michael; state: Exp; lines: +5 -2 fixed case insensitivity of TStrings.IndexOf ---------------------------- revision 1.14 date: 2002/12/10 21:05:44; author: michael; state: Exp; lines: +12 -5 + IndexOfName is case insensitive ----------------------------

Is there no other function that searches the list in a case insensitive way ? I've been looking through the current FCL source and speaking to a member of the list...

It seems perhaps I should write a descendant of TStringList, which I've done and works for my purpose.

The other query I have with TStringList, is the sqlite unit uses CommaText which replaces " with "" and other side affects you don't want in an IRC Services application. I'm going to have a find a way around this too. I've solved the problem of null values and quoted string returns from sqlite by a simple algorithm check.

function TDatabase.simpleQuery(query: String): String;
var
   tmp:  String;
begin
   if NOT (SQL = nil) then
      begin
         SQL.Query(query, nil);
         if (SQL.List_Field.count > 0) then
            begin
               S := TStringList(SQL.List_Field.items[0]);
               tmp := S.Strings[0];
               if (tmp[1] = '"') AND (tmp[length(tmp)] = '"') then
                  begin
                     if ((length(tmp) - 2) = 0) then
                        begin
                           simpleQuery := '';
                        end
                     else
                        begin
                           (* tmp := copy(tmp, 2, (length(tmp) - 1)); *)
                           tmp := copy(tmp, 2, length(tmp));
                           tmp := copy(tmp, 1, (length(tmp) - 1));
                           simpleQuery := tmp;
                        end;
                  end
               else
                  begin
                     simpleQuery := tmp;
                  end;
            end
         else
            begin
               simpleQuery := '';
            end;
      end;
end;

This works for what I need.

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape.

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 27 lines
On Wed, Aug 27, 2003 at 09:39:10AM +0200, Michael Van Canneyt wrote: > > > On Wed, 27 Aug 2003, James Mills wrote: > > > Hi, > > > > Is TStringList.indexOf case sensitive or insensitive ? > > TStrings.indexOf is case insensitive, but TStringList.indexOf overrides > > the TStrings.indexOf implementation accoriding to the documentation. > > It is case insensitive, but this was changed recently for Delphi > compatibility. > Older versions are case sensitive. Here are the relevant log entries: > > revision 1.15 > date: 2003/05/29 23:13:57; author: michael; state: Exp; lines: +5 -2 > fixed case insensitivity of TStrings.IndexOf > ---------------------------- > revision 1.14 > date: 2002/12/10 21:05:44; author: michael; state: Exp; lines: +12 -5 > + IndexOfName is case insensitive > ---------------------------- Is there no other function that searches the list in a case insensitive way ? I've been looking through the current FCL source and speaking to a member of the list...

No. IndexOf() is meant to search the list. In D7, there is a property 'CaseSensitive' which determines whether the search is performed case sensitively or not...

It seems perhaps I should write a descendant of TStringList, which I've done and works for my purpose.

This is always possible, that is why we have OOP.

The other query I have with TStringList, is the sqlite unit uses CommaText which replaces " with "" and other side affects you don't want in an IRC Services application.

Then you don't need commatext, but plain old 'text'. The idea of commatext is exactly that it replaces " with ""...

Michael.

Reply by email

James Mills
to Michael Van Canneyt
Michael Van Canneyt wrote 35 lines
On Wed, 27 Aug 2003, James Mills wrote: > On Wed, Aug 27, 2003 at 09:39:10AM +0200, Michael Van Canneyt wrote: > > > > > > On Wed, 27 Aug 2003, James Mills wrote: > > > > > Hi, > > > > > > Is TStringList.indexOf case sensitive or insensitive ? > > > TStrings.indexOf is case insensitive, but TStringList.indexOf overrides > > > the TStrings.indexOf implementation accoriding to the documentation. > > > > It is case insensitive, but this was changed recently for Delphi > > compatibility. > > Older versions are case sensitive. Here are the relevant log entries: > > > > revision 1.15 > > date: 2003/05/29 23:13:57; author: michael; state: Exp; lines: +5 -2 > > fixed case insensitivity of TStrings.IndexOf > > ---------------------------- > > revision 1.14 > > date: 2002/12/10 21:05:44; author: michael; state: Exp; lines: +12 -5 > > + IndexOfName is case insensitive > > ---------------------------- > > Is there no other function that searches the list in a case insensitive > way ? I've been looking through the current FCL source and speaking to a > member of the list... No. IndexOf() is meant to search the list. In D7, there is a property 'CaseSensitive' which determines whether the search is performed case sensitively or not...

I look at the source and didn't see a property like this. Maybe I'll check again :)
So if I went, strings.CaseSensitive := True;
it'd work ?

Show quoted text 14 lines
> > It seems perhaps I should write a descendant of TStringList, which I've > done and works for my purpose. This is always possible, that is why we have OOP. > > The other query I have with TStringList, is the sqlite unit uses > CommaText which replaces " with "" and other side affects you don't want > in an IRC Services application. Then you don't need commatext, but plain old 'text'. The idea of commatext is exactly that it replaces " with ""...

Well I've left the sqlite class to use commatext, but in my simple database class have used nsiExtractQuotedStr to remove double quotes and surrouding quotes in the string. using plain text adds extra 0A chars on the end.

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape.

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 41 lines
On Wed, Aug 27, 2003 at 03:03:31PM +0200, Michael Van Canneyt wrote: > > > On Wed, 27 Aug 2003, James Mills wrote: > > > On Wed, Aug 27, 2003 at 09:39:10AM +0200, Michael Van Canneyt wrote: > > > > > > > > > On Wed, 27 Aug 2003, James Mills wrote: > > > > > > > Hi, > > > > > > > > Is TStringList.indexOf case sensitive or insensitive ? > > > > TStrings.indexOf is case insensitive, but TStringList.indexOf overrides > > > > the TStrings.indexOf implementation accoriding to the documentation. > > > > > > It is case insensitive, but this was changed recently for Delphi > > > compatibility. > > > Older versions are case sensitive. Here are the relevant log entries: > > > > > > revision 1.15 > > > date: 2003/05/29 23:13:57; author: michael; state: Exp; lines: +5 -2 > > > fixed case insensitivity of TStrings.IndexOf > > > ---------------------------- > > > revision 1.14 > > > date: 2002/12/10 21:05:44; author: michael; state: Exp; lines: +12 -5 > > > + IndexOfName is case insensitive > > > ---------------------------- > > > > Is there no other function that searches the list in a case insensitive > > way ? I've been looking through the current FCL source and speaking to a > > member of the list... > > No. IndexOf() is meant to search the list. In D7, there is a property > 'CaseSensitive' which determines whether the search is performed case > sensitively or not... I look at the source and didn't see a property like this. Maybe I'll check again :) So if I went, strings.CaseSensitive := True; it'd work ?

In D7, yes. In FPC: Not unless you send me a patch :-)

Show quoted text 16 lines
> > It seems perhaps I should write a descendant of TStringList, which I've > > done and works for my purpose. > > This is always possible, that is why we have OOP. > > > > > The other query I have with TStringList, is the sqlite unit uses > > CommaText which replaces " with "" and other side affects you don't want > > in an IRC Services application. > > Then you don't need commatext, but plain old 'text'. > The idea of commatext is exactly that it replaces " with ""... Well I've left the sqlite class to use commatext, but in my simple database class have used nsiExtractQuotedStr to remove double quotes and surrouding quotes in the string. using plain text adds extra 0A chars on the end.

Yes. It is supposed to do this.

Michael.

Reply by email

James Mills
to Michael Van Canneyt
Michael Van Canneyt wrote
In D7, yes. In FPC: Not unless you send me a patch :-)

Perhaps I will. It's rather a waste of code to create an entire desandant :)

cheers
James

- -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape.

Reply by email