www.kxcad.net Home > Electronic Index > Altium(Protel) Index
Declaration
Var
AFile : File;
AFile : TextFile;
Description
A file is a binary sequence of some type. A file contents are usually stored in a persistent storage such as a hard disk. Before a file variable can be used, it must be associated with an external file through a call to the AssignFile procedure. An external file is typically a named disk file. Once the association with an external file is established, the file variable must be opened to prepare it for input or output.
An existing file can be opened via the Reset procedure and a new file can be created and opened via the Rewrite procedure. To read contents of a file, use Read/ReadLn statements and to write contents to a file, use Write/Writeln statements. When a script completes processing the file, it must be closed using CloseFile procedure.
Example
Var
InputFile : TextFile;
OutputFile : TextFile;
I : Integer;
Line : String;
Begin
AssignFile(OutputFile,eConvertedFile.Text);
Rewrite(OutputFile);
AssignFile(InputFIle,eOriginalFIle.Text);
Reset(InputFile);
Try
While not EOF(InputFile) do
Begin
Readln(InputFile,Line);
For I := 1 to Length(Line) Do
Line[I] := UpperCase(Line[I]);
Writeln(Outputfile, Line);
End;
Finally
CloseFile(InputFile);
CloseFile(OutputFile);
End;
End;
See also
Append, AssignFile, CloseFile, ChDir, MkDir, Read, ReadLn, RmDir, Write and Writeln functions.