Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking Arrays

Status
Not open for further replies.

minckle

Programmer
Mar 17, 2004
142
GB
I have
testArray: Array[0..10] of String;
testButton: TButton;
saveButton: TButton;

the first time i click the button i want to see all the elements of the array.
When i click the save button i want to save the amended array.

The first time i click the testButton i get an error because nothing is in the array yet (on debug the array show inaccessible value). how do i check the array to see if anythings in it????

I dont have a problem with showing or saving the array.

hope you understand what i trying to say

 
If you're filling the array with strings, why not use a TStringList instead? I think all of TMemo, TListbox, etc. type components use a TStringList to show their data. IMHO, a TStringList is also easier to manipulate than an array and if you put the "create" for the stringlist in the OnCreate event handler, you don't have to worry about whether there's anything in it or not.

-Dell
 
Sorry i was just to trying to describe the problem in an easy way, Im actually storing a series of objects in the array, so it needs to be an array i think
 
if assigned(testArray) then

use the assigned function check the array

 
you can use a TObjectlist if you want. it has some nice features like freeing the object if you remove it from the list...

--------------------------------------
What You See Is What You Get
 
TStringList also has an Object property, so instead of using the Add method you use the AddObject method which will add the object with an association to the string you're adding at the same time.

-Dell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top