Solved

Make a listbox item active from a read in text file

Posted on 1997-05-16
2
229 Views
Last Modified: 2011-09-20
Hi

I have successfuly put together most of my first app and I'm very impressed with this language.

The problem is that I need to be able to read a short text file into a form's components, modify the form and write the text file back out.

I can make this work with TEdit boxes, but when I try to readln a line, I can capture the line but am unable to make it show up in a list box as the highlighted item

line 2 of text file = "USR 28.8 External"    I need this to be the active entry in a list box as such


LISTBOX1 STRINGS
Cardinal 28.8 Internal
Cardinal 33.6 External
USR 28.8 External   (>THIS NEEDS TO BE THE ACTIVE LINE)
Zoom ~~````                 (OF THE LIST BOX)


My second part of my problem is with another list box. I can read a file into it and delete an item from it, but how do I rewrite the remaining lines back out to the original file such that the deletede entry is not in the re-writen text file..

Any help would be most appreciated

Thanks In Advance



Chris

0
Comment
Question by:chrisj051697
2 Comments
 
LVL 1

Accepted Solution

by:
sleach earned 100 total points
ID: 1336368
part 1:

for x := 0 to ListBox1.items.count-1 do
begin
  if ListBox1.items[x] = 'USR 28.8 External' then
     ListBox1.itemindex := x;
end;

part 2:
ListBox1.items.loadFromFile('FileName');
{make changes...}
ListBox1.items.SaveToFile('FileName');

0
 

Author Comment

by:chrisj051697
ID: 1336369
Thanks for the help

With part 1, I was getting a type mismatch error in the "if" staement.  Put this looks like is does the job. I'll have to figure out what I was doing wrong

For part two, I was playing with "Assign File" routines. This looks much cleaner.

Chris
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

15 Experts available now in Live!

Get 1:1 Help Now