Solved

An easy delphi question

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add combobox item based on numbers 9 141
Create Database on Android via Delphi dbExpress 3 90
Intraweb download file link ? 1 132
How to convert memory stream to PDF file 6 55
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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