Solved

Casting a TList Item

Posted on 1997-06-10
1
531 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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