Solved

Casting a TList Item

Posted on 1997-06-10
1
524 Views
Last Modified: 2012-05-07
How can I cast a TList item?  I have a TList object that contains TStringLIst objects.  I want to do a find on the TSTringList, but I can't cast it.  Here are the things I have tried:

   MyString := MyTList.Items[0].Strings[0] ;
Error: Record, object, or class type required.

   MyString := (MyTList.Items[0] as TStringLIst).Strings[0] ;
Error: Operator not applicable to this operand type.

I realize that MyTList.tems[0] is actually returning a pointer, but I can't figure out how to turn that into something I can use.  I also realise that I can assign MyTList.Items[0] to a temporary variable that is typed as a TStringList, but that is a pain in the ass.  It also makes the code a lot more complicated when I am looping through a TList of TStringLIsts.

-- Clayton --
0
Comment
Question by:Clayton Neff
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 100 total points
ID: 1336928
Like this:

MyString := TStringList(MyTList.Items[0])[0];

/// John

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now