Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to implement a stack (of strings)?

Posted on 2000-02-28
8
Medium Priority
?
121 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 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

715 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