Need code quick. How to add text to Memo and delete/add things on user input?
Posted on 2006-06-17
Usually I would try to figure this out, but I just don't have time so I thought I'd ask here.
Basically I am trying to write a program that reads a file (which is a list of files that have a number/letters in front of them, which are a specific length e.g. 8 characters). I need the program to open a file and read it and put that info in the Memo. Then I want a Userinput box where the user enters how long the number at the beginning is, and then click a command button to delete the characters.
This is the code I was trying to use to open the file
procedure TForm1.Open1Click(Sender: TObject);
//open a data file, reading it line by line
OpenDialog1.Filter := 'Text files (*.txt)|*.TXT';
if OpenDialog1.Execute then
Filename:= OpenDialog1.FileName; //assign opendialog1.filename to the filename
Reset(DataFile); //reopen file
while not eof(DataFile) do
memo1.text := Currentline;
Then I was going to use a similar code to delete the characters
delete(CurrentLine, 1, UserInput); - where userinput is an integer value that the user has entered.
I know this will be really easy for someone to do. I will give A to whoever does it.
Thanks in advance.