roadie031198
asked on
text files for I/O
{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.
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.
You need create a variable like this
var VariableName:Text;
buffer:string;
Then you can try open the file:
AssignFile(VariableName,"P hysicalNam e 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!!!!!!
var VariableName:Text;
buffer:string;
Then you can try open the file:
AssignFile(VariableName,"P
Rewrite(LogFile); {Clear and open the file}
If you want write
Write(VariableName,"text that you want write")
or
Writeln(VariableName,"text
If you want read from file
Readln(VariableName,buffer
When you finish
CloseFile(VariableName).
If you have doubts, write again. GoodLuck!!!!!!
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!
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks alot
sorry for the late reply
sorry for the late reply
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!
ASKER