Solved

Make a listbox item active from a read in text file

Posted on 1997-05-16
2
250 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
[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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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