[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] |
Read data from an untyped file into memory
Source position: line 0
procedure BlockRead( |
var f: file; |
var Buf; |
count: Int64; |
var Result: Int64 |
); |
var f: file; |
var Buf; |
count: LongInt; |
var Result: LongInt |
); |
var f: file; |
var Buf; |
count: Cardinal; |
var Result: Cardinal |
); |
var f: file; |
var Buf; |
count: Word; |
var Result: Word |
); |
var f: file; |
var Buf; |
count: Word; |
var Result: Integer |
); |
var f: file; |
var Buf; |
count: Int64 |
); |
Blockread reads count or less records from file F. A record is a block of bytes with size specified by the Rewrite or Reset statement. The result is placed in Buffer, which must contain enough room for Count records. The function cannot read partial records. If Result is specified, it contains the number of records actually read. If Result isn't specified, and less than Count records were read, a run-time error is generated. This behavior can be controlled by the {$I} switch.
Depending on the state of the {$I} switch, a runtime error can be generated if there is an error. In the {$I-} state, use IOResult to check for errors.
|
Write data from memory to an untyped file |
|
|
Close a file |
|
|
Open file for reading |
|
|
Assign a name to a file |
Program Example6; { Program to demonstrate the BlockRead and BlockWrite functions. } Var Fin, fout : File; NumRead,NumWritten : Word; Buf : Array[1..2048] of byte; Total : Longint; begin Assign (Fin, Paramstr(1)); Assign (Fout,Paramstr(2)); Reset (Fin,1); Rewrite (Fout,1); Total:=0; Repeat BlockRead (Fin,buf,Sizeof(buf),NumRead); BlockWrite (Fout,Buf,NumRead,NumWritten); inc(Total,NumWritten); Until (NumRead=0) or (NumWritten<>NumRead); Write ('Copied ',Total,' bytes from file ',paramstr(1)); Writeln (' to file ',paramstr(2)); close(fin); close(fout); end.
lazarus-ccr.sourceforge.net |