?
Solved

Casting a TList Item

Posted on 1997-06-10
1
Medium Priority
?
550 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

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

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

/// John

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

770 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