file_obj_bin
Synopsis
file_obj_bin (file, offset, type [,stride])
Description
file_obj_bin reads a binary array or binary scalar from the file object. It starts reading data at the offset position which is specified in bytes. file_obj_bin reads a number of bytes corresponding to the type value and dimensionality of the referencing object. It reports an error if it reaches the end of file before the target object is filled.
Note: file_obj_bin does not perform byte-swapping necessary to read binary files created on foreign platforms that use incompatible binary data formats.
Parameters
Object of type FILE.file that identifies the file that will be accessed. Note that this is not a string holding the filename. See the example.
An array of 1s and 0s that represents words in the lines of an ASCII file. It indicates whether or not to read the words. This parameter is not used for binary files.
An optional integer value that specifies how many "strides" must be taken to get to the next data value. It is relevant only for binary files, if is omitted, 1 assumed.
Example 1
A binary file, myData.bin, has an array of integers. The example below demonstrates how to read the third integer:
file data_file {
name = "myData.bin";
};
int value => file_obj_bin (data_file, 8, 3);Note that the offset is calculated in bytes. A value of 8 indicates that the first two integers in the file are ignored.
Example 2
The binary file, myData, contains an array of integers. The example below demonstrates how to read 100 integers, starting from position 200 in the file.
file data_file {
name = "myData";
};
int values[100] =>file_obj_bin (data_file,200,3);Additional Examples
v/dv_examp/file_ucd.v
v/dv_examp/file_unif.vFile
See also related modules