Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to implement a stack (of strings)?

Posted on 2000-02-28
8
Medium Priority
?
123 Views
Last Modified: 2010-04-04
I need to use a stack that stores strings in my app, and I've tried using listboxes, but there has GOT to be a better way to do it.
besides, with listboxes, I get a very strange error:
if I do:
listbox.items.add('string');
the stupid thing adds an empty string to the box... WHYYYYYYYYY????

going in sane with Delphi 4....(wanna join me?)
0
Comment
Question by:Tguruwannabe
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:TheNeil
ID: 2565700
Try using a TStringlist instead. It works similarly to a TListbox but it's faster and isn't visual.

All you need to do is declare it as a variable, create it, use it, then destroy it.

e.g.

VAR
  stlTemp : TStringList;
  iCount  : INTEGER;
BEGIN
  stlTemp := TStringList.Create;

  stlTemp.Add('Some text'):
  stlTemp.Add('Some more text');
  FOR iCount := 0 TO (stlTemp.Count - 1)
  DO
    MessageDlg('Data: ' + stlTemp[iCount], mtInformation, [mbOk], 0);

  stlTemp.Free;
END;

Hope that helps and if you need any help then just ask

The Neil
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 2567808
?
listbox.items.add('string');
the stupid thing adds an empty string to the box... WHYYYYYYYYY????

could not recognise this
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2568854
?
thanks for the points ;-),
but for what ?
(guessing you don't want accept my comment as an answer)

0
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.

 
LVL 5

Expert Comment

by:TheNeil
ID: 2568871
Err what's going on here? No offence kretzschmar but did you submit a solution while I wasn't looking?

Weird

The Neil
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2568883
hi theneil,
just wondering also,
because i hadn't submit a solution, just a comment that i can't reproduce the problem, as you can see.
meikl
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2569163
I'm not complaining or anything but I'm like you, I just can't see what's going on

The Neil
0
 

Author Comment

by:Tguruwannabe
ID: 2569777
I apologize kretzschmar and TheNeil, the second problem I was describing was happening on my system, but I still don't know why.  I fixed it though.  (by carefully cleaning up the code for the whole program)...  maybe I was messing around with memory locations that were off limits.
Thanks for your suggestion TheNeil, I implemented it and it works great.
By the way i'm new to this thing and I still haven't figured out this thing works as far as getting and giving points.

Tguruwannabe
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2569921
well Tguruwannabe,

thats some clearer now for us.
then i've got points which should deserved by theneil.

you should ask a 0-point question in
the ex-ex community support
(see links at button of this page),
and tell there the mistake (about the wrong grading)
so that the neil can get his points

glad that you get it work
good luck again

meikl
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

783 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