With the help with another TStrings instance!

Store the name of each of your TStrings along with their reference in the 
helper TStrings by using AddObject method. Later you can get the referense to 
the respested TString by using the helper TStrings IndexOf('TString name'), and 
use the returned index in the helper TString Objects property. Of course you 
need to typecast it back to TString.

Here is the code snippet.

// store the TStrings names and references
// maybe in constructor

  FMyStrings.AddObject('String1', FString1);
  FMyStrings.AddObject('String2', FString2);
  ..
  ..


// Now getting back the Tstring reference from 
// its name
function FindMyTStrings(const AName: string; var AStrings: TStrings): Boolean;
var
   i: Integer;
begin
   i := FMyStrings.IndexOf(AName);
    Result := i > -1;
    if Result then
        AStrings := TStrings(FMyStrings.Objects[i]);
end;


Cheers!
Luthfi



--- On Thu, 2/4/10, lv_solutions <lvs.m...@lvsinc.net> wrote:

From: lv_solutions <lvs.m...@lvsinc.net>
Subject: [advanced_delphi] Refrence TString by its name
To: advanced_delphi@yahoogroups.com
Date: Thursday, February 4, 2010, 9:45 PM















 
 



  


    
      
      
      Beginner.



I have a class in which I have a few Tstring lists.



I now want to access those string list by their name from  a sting the user 
enters in a edit box.



How do I do this?



Delphi 7





    
     

    
    


 



  











      

Reply via email to