AuthorMessage
NeiSep
Ametuar
Posts: 93

Hello there..
i got a problem with reading a line from a file let say i got alot of text in a text document like accounts or so
NeiSep
sdfjskjdfjskdjf
sdjfkjskdf
PowerRangers
skjfosjdflklsdkfoiosidofuoieoiroise
we say that this is the file okey so we got 2 lines NeiSep and PowerRangers that is intresseting.
And what do i want well to Read the whole line PowerRangers and first we need to know wich line PowerRangers is on and i dont get how to count out that anyone know ?
Its probly very easy but i have try several stuff in almost 2 weeks now without success.
So im in really need of help here lol.
Have a very very nice day 
Mickey
Ametuar
Posts: 115

It is not clear what you want. You can access a text file row by row only. I advise you to read some Pascal books to be clear with Pascal basics. Don't jump in deep water  in Windows programming.
Code:
type
 MyTextFileType = text;
var
  Form1: TForm1;
  MyTextFile: MyTextFileType;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
  MyFileName, s: string;
  i : Integer;
begin
  MyFileName := 'TextFileName.txt';
  AssignFile(MyTextFile, MyFileName);
  i := 0;
  try
    Reset(MyTextFile);
    try
      s := '';
      repeat
        ReadLn(MyTextFile,s);
        Inc(i);
      until Eof(MyTextFile) or (s = 'PowerRangers');
    finally
      CloseFile(MyTextFile);
    end; // try...finally
  except
    // Error handling here
    on E:EInOutError do
      MessageDlg(E.Message, mtError, [mbAbort], 0); // Default error message by system.
  end; // try...except
  ShowMessage('PowerRangers was in ' + IntToStr(i) + 'th row of text file.');
end;

NeiSep
Ametuar
Posts: 93

o hehe never tought it was so simpel lol well thanks anyway.
Mickey
Ametuar
Posts: 115

Quoted from NeiSep
o hehe never tought it was so simpel lol well thanks anyway.

Object Pascal is pretty simple you just need some basics. There are many good Pascal books good to lay the foundations of basics Pascal then you can go Object Pascal.
In Borland Pascal file handling was not so good as in Object Pascal.
I will show how BP did it soon.