Solved

How to implement a stack (of strings)?

Posted on 2000-02-28
8
119 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
[X]
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
  • 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 50 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
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…

751 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