Solved

An easy delphi question

Posted on 2003-11-26
5
196 Views
Last Modified: 2010-04-05
i need to write a program.
Source contains a number of strings, each on a seperate line. Read the
strings one at a time printing them to the screen until contained in finish is
read or the end of the file is reached. Write to the screen a message stating
which occured first. The strings are to be considered case sensitive.

i can read the data until the end of file if found, but after that im stuck.. any ideas???
0
Comment
Question by:jarhys
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
TheLeader earned 25 total points
ID: 9828630
do you mean show the result of the file
you should make an output file, or memo if you would like

assign ( ...... )   //  if you would like to create an output file
rewrite( ..... )   // to make it ready for writing result

or
memo1.text :=  ........


anyway, you said idea, if you would like the code i can write it.

is this what you meant !?
0
 
LVL 2

Expert Comment

by:TheLeader
ID: 9828642
ofcourse you can do what ever you want after the condition


if FileExist ({filename & location})
if Eof(fileinput) then
...
// do what ever you want

hope it helped
0
 
LVL 17

Assisted Solution

by:geobul
geobul earned 25 total points
ID: 9831383
Hi,

program Project1;
{$APPTYPE CONSOLE}
uses
  SysUtils;

var
  f: textfile;
  fname: string;
  EndLine: string;
  line: string;
begin
  // enter some data
  Write('Enter filename:');
  Readln(fname);
  Write('Enter stop line (case sensitive):');
  Readln(EndLine);
  // open the file
  if FileExists(fname) then begin
    Assign(f, fname);
    Reset(f);
    while not EOF(F) do begin
      Readln(f, line);
      Writeln(line);
      if line = EndLine then begin
        Writeln('Stop string has been found');
        break;
      end;
    end;
    if EOF(f) then Writeln('End of file has been reached');
    CloseFile(f);
  end else begin
    Writeln('File does not exist');
  end;
end.

Regards, Geo
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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