Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

An easy delphi question

Posted on 2003-11-26
5
Medium Priority
?
200 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
[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
5 Comments
 
LVL 2

Accepted Solution

by:
TheLeader earned 100 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 100 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

688 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