[yunqa.de] Re: Newbie still struglling with DISQLite 3

  • From: "Michael Hooker" <michael.hooker@xxxxxxxxxxxxxxxxxxxxx>
  • To: <yunqa@xxxxxxxxxxxxx>
  • Date: Fri, 11 Jul 2008 21:40:13 +0100

Hi. I think this may be a Delphi StringList problem, not a DISQLite problem. Though it's a bit hard to tell as you don't say what error messages you are getting.


You won't find anything in a string list using ".IndexOfName" unless the string list is a set of Name=Value pairs, ie "4009E4=G-TTOH". If you search for the hexcode 4009E4 it will return the index of the line so you can extract the value "G-TTOH". See the help in Delphi under IndexOfName. There are other useful related keywords such as V := MyStringList.Values(Edit1.Text), which would directly return the value part of the pair in the string variable V if the Name part is supplied in the Edit control. Brilliant - instant look-up table.

The keyword to find an item in an ordinary TStringlist is .Find - it returns the index of the relevant string if found - but note you should set the stringlist to "Sorted" or it won't work. The TStringList.Find item in the Delphi help should explain this. But it won't find part of a string, only a whole string.

Hope that helps. I'm not a DISQLIte3 expert by any means, but I do use it to get data from the BaseStation.sqb file I know you're talking about into StringLists so I may be able to help if you want to correspond direct.

Michael Hooker


--------------------------------------------------
From: "dogo" <dogo_daz@xxxxxxx>
Sent: Friday, July 11, 2008 5:11 PM
To: <yunqa@xxxxxxxxxxxxx>
Subject: [yunqa.de] Re: Newbie still struglling with DISQLite 3

Hi,

I've been playing with the stringlist demo, and have modified it a bit.. No doubt I have made it Worst :-( what I am now trying to do is match the text from the edit1.textbox to an item in my string list, but I am having no luck
could someone point me in the right direction.

Cheers and sorry for all the questions

Darren

procedure TfrmStringList.btnSelectClick(Sender: TObject);
const
 SelectSQL = 'SELECT * from aircraft';
var
 Stmt: TDISQLite3Statement;
 i: Integer;
begin
 MyStringList := TStringList.Create;

                                  //
 try
   MyStringList.Delimiter := ',';
   Stmt := FDatabase.Prepare16(SelectSQL);
   try

     while Stmt.Step = SQLITE_ROW do
     begin
       MyStringList.AddObject(Stmt.Column_Str16(3), // The Name.
         TObject(Stmt.Column_Int(0))); // The ID, stored as TObject.
     end;
   finally
     Stmt.Free;
   end;
 finally
   myStringList.EndUpdate;
   for i := 0 to MyStringList.Count - 1 do
   begin

//   ShowMessage(MyStringList[i]);
   end;
 end;

end;

//--------------------------------------------------------------------------
----

procedure TfrmStringList.FindBtnClick(Sender: TObject);
var
 i: Integer;
begin
 for i := 0 to MyStringList.Count - 1 do
 begin
   if MyStringList.IndexOfname(Edit1.Text) = -1 then
     ShowMessage('Found');
 end;
end;




__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3262 (20080711) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa





_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: