Home • ECDL • Algoritmi • Java • Basi di dati • Seconda prova • Eccetera • Cerca nel sito

File: sintassi

Precedente
SUPERIORE
Successiva

A "file" type consists of a linear sequence of components of the component type, which can be any type except a file type.

Syntax: file of type OR file

If the word "of" and the component type are omitted, the type denotes an untyped file.

The predefined file type Text signifies a file containing characters organized into lines.

Example: { File type declarations }

Type
   Person = Record
      FirstName: String[15];
      LastName : String[25];
      Address  : String[35];
   end;
   PersonFile = File of Person;
   NumberFile = File of Integer;
   SwapFile   = File;
Assign
Assign(var f; name: string); 
Assigns the name of an external file to a file variable.
Reset
Reset(var f [: file; recsize: Word ] ); 
Opens an existing file.
Rewrite
Rewrite(var f: file [; recsize: Word ] ); 
Creates and opens a new file.
Close
Close(var f); 
Closes an open file.

Append

Append(var f: text); 
Opens an existing file for appending (f is a text-file variable).
Truncate
Truncate(var f); 
Truncates the file at the current file position.
Read
Read(f , v1 [, v2,...,vn ] );
For typed files, reads a file component into a variable.
Read( [ var f: text; ] v1 [, v2,...,vn ] );
For text files, reads one or more values into one or more variables.With a type string variable, Read reads all characters up to, but not including, the next end-of-line marker or until Eof(f) becomes True; it does not skip to the next line after reading.After the first Read, each subsequent Read will see the end-of-line markerand return a zero-length string.Use multiple Readln calls to read successive string values.
Write
Write(f, v1 [, v2,...,vn ] );
For typed files, writes a variable into a file component.
Write( [ var f: text; ] v1 [,v2,...,vn ] );
For text files, writes one or more values to the file.
ReadLn
ReadLn([ var f: text; ] v1 [, v2, ..., vn ] );
Executes the Read procedure, then skips to the next line of the file.After executing Read, Readln skips to the beginning of the next line of the file.
WriteLn
WriteLn([ var f: text; ] v1 [, v2, ..., vn ] );
Executes the Write procedure, then outputs an end-of-line marker to the file.
Eof
Eof(var f): Boolean;
Eof [ (var f: text) ]: Boolean;
Returns the end-of-file status.
Eoln
Eoln [(var f: text) ]: Boolean;
Returns the end-of-line status of a text file
FilePos
FilePos(var f): Longint;
Returns the current file position of a file.
FileSize
FileSize(var f): Longint;
Returns the current file position of a file.
Seek
Seek(var f; n: Longint);
Moves the current position of a file to a specified component.
Erase
Erase(var f);
Erases an external file.
Rename
Rename(var f; newname: string);
Renames an external file.

File: sintassi - ApPuNtIdIuNiNfOrMaTiCo

Home • ECDL • Algoritmi • Java • Basi di dati • Seconda prova • Eccetera • Cerca nel sito

Precedente
SUPERIORE
Successiva