Solved

Make a listbox item active from a read in text file

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

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