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
Solved

Easy, I think!

Posted on 1998-03-23
1
147 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

829 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