Dear All,

I need help to do the interface delphi program as the following:

1. Allow the use to select a text file from a storage media.

2. Open the text file and read it line by line.

3. scan each line and extract each word

4. write each word one by one in a memo box.
Waiting for you.
Best Regards,
NOna

The Version that I use is Delphi 2007

What do you have so far, what exactly have you struggled with?

Till No I did the following:


type
TForm2 = class(TForm)
ExitButton: TButton;
Memo1: TMemo;
OpenButton: TButton;
OpenDialog1: TOpenDialog;

var
Form2 :TForm2;
MyFile, NewFile :TextFile;
Line :String;
I,J :Integer;
Ch :Char;


procedure TForm2.OpenButtonClick(Sender: TObject);
begin
OpenDialog1.Execute;
AssignFile(MyFile,OpenDialog1.FileName);
Reset(MyFile);
I := 0;
J := 0;

While I > 0 do
Repeat
Read(MyFile,Line);
Write(MyFile,Line);
Memo1.Lines.LoadFromFile(Line);
I := I + 1;
if Line <> ' ' then
//Memo1.Lines.LoadFromFile(Line[J]);
//J := J+1;
//I := J;
Until EOF(MyFile);

CloseFile(MyFile);
end;

procedure TForm2.ExitButtonClick(Sender: TObject);
begin
Form2.Close;
end;
end.

I'm familiar with C++, Delphi is little Like C++, but there is alot of functions (I don't know how to deal with)

In my program above (It's work, but nothing appear in the memo, and how can I start a new line to continuo write in the memo (Word be Word).

Please help me this is one of my assigment and I have to finish it before Tuseday.

Best regards,
Nour

The unit sysUtil.pas has a number of string routines including several that can be used to search through the string to find the spaces between words and allow you to extract the words individually for each line.

Dear friend,

"The unit sysUtil.pas has a number of string routines including several that can be used to search through the string to find the spaces between words and allow you to extract the words individually for each line"

I con't understand what do you mean, would you please write an example.

Best regards,
NOna

If you look in the directories where your Delphi program is located on your computer under the ...source/win32/rtl/sys directory you will find the file sysutils.pas. This file contains a number of methods (C++) or PRocedures and functions (Delphi) which provide capabilites to find, add, or delete text in a string. amoungst other things. Read through the declarations and you will have a better idea how to use the procedures. To use them in your program add "Sysutils" to your "Uses" statement at the beginning of your program code. IF you are unfamiliar with the Delphi environment and how to use it, check out this site:
http://blogs.codegear.com/nickhodges/2006/08/15/26687.
The demonstrations are very good for getting a handle on coding in Delphi.

Dear jsosnowski,

Thank you very much for help, I knew about the directory of Delphi but as my final exam after a week I don't have time to find it, any way thanks for help again.

Regards,
NOna

Good Luck on your exam.

which type of file were you intending to open, a textfile?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.