Solved

How to implement a stack (of strings)?

Posted on 2000-02-28
8
116 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using idhttp to login to instagram 2 91
Delphi selector screen 2 80
Dev Express grid collapse 2 45
can i put an image from resource into image tag ? 6 25
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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