#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Location
    Australia, Sydney
    Posts
    12
    Rep Power
    0

    Question Reading content of a text file....


    Hi,

    I am using the OpenDiag component to open a file, but after open a file i want to read the contents of that file into my Memo field...

    How can i do this?
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Romania
    Posts
    173
    Rep Power
    11
    See the Delphi help >> Text File Routines ... everything you need is there !

    Good luck,
    Silver
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    Heh, the TStringList object (i.e. Memo.Lines) has a LoadFromFile method. You can use this to read data from a file into a memo. Something like this ought to do the trick:
    Code:
    if OpenDialog1.Execute then
         Memo1.Lines.LoadFromFile(OpenDialog1.Filename);
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    52
    Rep Power
    11
    it depends how you want to read it?

    is it just normal text/
    comma, comma delimated, tab data?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Location
    Australia, Sydney
    Posts
    12
    Rep Power
    0
    Its just a normal text file, i also came cross thse 2 ways of doingit:

    QueryInput.Lines.LoadFromFile(OpenDialog1.FileName);


    AND

    AssignFile(myFile, OpenDialog1.FileName);
    Reset(myFile);

    while not Eof(myFile) do
    begin
    ReadLn(myFile, querytext);
    QueryInput.Lines.Add(querytext);
    end;

IMN logo majestic logo threadwatch logo seochat tools logo