Solved

How to implement a stack (of strings)?

Posted on 2000-02-28
8
114 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 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 85
APK file name 7 63
drawing animated level bar based on numbers 3 72
Create a path if not exists 7 44
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now