Solved

Make a listbox item active from a read in text file

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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