Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

text files for I/O

Posted on 1998-03-11
6
Medium Priority
?
135 Views
Last Modified: 2010-04-06
{I'm just started learning Delphi this week }
I need a program to write real numbers and string text to a textfile and read them out to a 2 dimensional array and preform some calculations and output onto the form.

If you could help me out with answers or sample code that'd be great.
0
Comment
Question by:roadie031198
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:roadie031198
ID: 1360409
Edited text of question
0
 

Expert Comment

by:Marcelito
ID: 1360410
You need create a variable like this

var VariableName:Text;
     buffer:string;

Then you can try open the file:

   AssignFile(VariableName,"PhysicalName of file (on disk)"); { Map variable to a real file}
   Rewrite(LogFile); {Clear and open the file}

If you want write
 
   Write(VariableName,"text that you want write")

or

  Writeln(VariableName,"text that you want write")

If you want read from file

  Readln(VariableName,buffer) {Read one line from the file and set to next line}

When you finish
 
  CloseFile(VariableName).

If you have doubts, write again. GoodLuck!!!!!!




0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360411
Yo roadie,

That VariableName can be everything.

eg. You want to write strings (chars) to a file :
           VariableName : File of char
                                  or  File of String
                                  or  Text  (Short for File of String)
     You want to write numbers ? :
           VariableName : File of integer
                                  File of real;
     You want to write records ? :
          Score = RECORD
            Name : string[50];
            Value : Real;
          End;
           
                  --> VariableName : Score

......... and keep going on, on, on, on ...............

Regards, Zif.

Nice to hear about newcommers.

Succes!
     
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Accepted Solution

by:
williams2 earned 200 total points
ID: 1360412
Why don't people keep it simple to beginners, I wouldn't understand a bit of it (No offence), here's some sample code:

Procedure WriteToFile(FileName,Text: String);
var
  F: File of text; //Pascal Style
  //F: Textfile; //Delphi style
Begin
  Try
    AssignFile(F,Filname);
    FileMode:= fmOpenReadWrite; //See Delphi help File-mode constants.
    Reset(F);
    WriteLn(F,Text);
    //Write(F,Text);
    //Write(F,Text,' Hello World ');
  Finally
    CloseFile(F);
  End;
End;  
 
0
 

Author Comment

by:roadie031198
ID: 1360413
thanks alot

sorry for the late reply
0
 
LVL 3

Expert Comment

by:williams2
ID: 1360414
Don't mention it. If you have found it usefull, that's satisfaction enough to me. The others somehow did come up with different and correct answers, but it happens too often that experts don't seem to come up with simple answers, and that's a hint to everyone. Keep it simple!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 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