Solved

Easy, I think!

Posted on 1998-03-23
1
142 Views
Last Modified: 2011-09-20
Hi,
     I want to take info from the user into a TStringList. Firstly, there is no component associated with the stringlist, so do I declare it in the  unit's type declaration, or as a variable?
    The info is taken from an edit box. So I tried writing this:

var
   mylist : TStringList;
begin
   mylist.Add(edit1.Text);
end;

When I run this, it compiles OK, but when I try to use it, it says 'EGPFault'. Do I have to instantiate the TStringList anywhere?
Cheers, Nik

0
Comment
Question by:NikWhit
1 Comment
 
LVL 4

Accepted Solution

by:
d003303 earned 10 total points
ID: 1360735
Right, you must create an object before you use it and free it afterwards. So your code should read

var
   mylist : TStringList;
begin
   myList := TStringList.Create
   mylist.Add(edit1.Text);
   // whatever code...

  myList.Free;
end;

If you want to use myList globally, put it into your forms private variables and create it in OnCreate and free it in OnDestroy.

Slash/d003303
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
APK file name 7 64
Best Firemonkey component pack 1 73
oracle global variables 4 52
how can i search if string exist in array ? 3 31
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

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

21 Experts available now in Live!

Get 1:1 Help Now