sFile | (String) The file name with the path.
If a full path is not entered, then it is completed relative to the application folder. It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files or folders. |
---|---|
nOffset | (Long) Byte offset that sets the beginning of reading from the binary file (e.g. 10 means reading from 10th byte of the file). |
nAttr | (Long) Bit attribute. It can be 0 or a sum of the following applicable values:
1 - Flag that neither the number nor the type of read data is known. The method in this case creates a new array in the Values parameter with the length equals to FILE_LENGTH - OFFSET, whose items are of the Byte type.
If the value 1 is not entered, then the Values parameter must be set to data type of the array (Array) before calling. Data are than read from the file into the array sequentially according to the data types of this array items. 2 - Flag how to read the text string (String), i.e. how to get its length. If the value is entered, then it's presumed that in the item of the Values array is already a text string of the specified length. From the file so many characters are read into the item how many there are they in the input string (the input string is then overwritten by the same number of characters from the file). In this case the value of the binary 0 shouldn't appear in the file on the place that is referred to such text.
If the value is not entered, then characters from the file are read into the item of the String type until a byte with value 0 is encountered. Data in the text string form can be read only if the 1 value is not set in the nAttr parameter. |
Values | (Variant) Variable of the Array type into which binary data are read. |
Data type: | Number of read bytes from the file: |
---|---|
Byte | 1 |
Integer | 2 |
Long | 4 |
Date | 8 |
Bool | 1 |
Single | 4 |
Double | 8 |
String | number of characters + 1 (1 for the character 0, only if nAttr=2 is not set) |
Dim Length, Val
Val = Pm.Array1(CByte(0), CLng(0), "12345")
Length = Pm.FileBinaryRead("#data:File.bin", 0, 2, Val)
If Length = 1+4+5 Then
Pm.Debug("Data successfully read. List of items follows:")
Pm.Debug Val, 1
Else
Pm.Debug "Reading data failed! Length=" & Length
End If
Dim Length, Val
Length = Pm.FileBinaryRead("#data:File.bin", 0, 1, Val)
If Length > 0 Then
Pm.Debug("Data successfully read. List of items follows:")
Pm.Debug Val, 1
Else
Pm.Debug "Reading data failed! Length=" & Length
End If