Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 4th, 2012, 12:55 AM
want2knowdelphi want2knowdelphi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 1 want2knowdelphi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 12 sec
Reputation Power: 0
Smile Load Text From File in Delphi

hello,,
i m a beginner in delphi,,
now i m so confused about load text from file,,
before, i made a program in delphi which save text in a file
Ex : delphi 123456
i want when i click load button, delphi in Edit1 and 123456 in Edit2
plz help me
NB : sorry for my bad language

Reply With Quote
  #2  
Old March 4th, 2012, 06:31 PM
clivew clivew is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 2,045 clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 37 m
Reputation Power: 382
It is hard to know from your post how complex your situation or how large the text files
might become.

If the text files will fit comfortably in memory and you only want to break the file into
strings based upon carriage returns (as implied by readln) then you could just load the
file into a stringList.

Simplistically
Code:
procedure TForm1.LoadFile;
var
  myStrings: TStringList;
begin
   myStrings := TStringList.Create;
   try
     myStrings.LoadFromFile('drive\path\filename.txt');
     // Do what you want here
     // e.g. Edit1.Text := myStrings[0];
   finally
     myStrings.Free;
   end;
end;


Ofcourse, you may want the TStringList to be more permanent and be available for
interaction with the user. In such a case you might want it to be created in FormCreate.
The example I gave is just to illustrate loading the file and accessing the first line.

Clive

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Load Text From File in Delphi

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap