Solved

An easy delphi question

Posted on 2003-11-26
5
192 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now