Update cookies preferences
Promotic

FileBinaryWrite - method of the Pm object

Description:
Saving the content of the variable of the Array type (array of values) into the binary file.
This method is obsolete (but functional) and it is better to use the PmBuffer.SaveToFile method.
Syntax:
Long FileBinaryWrite(String sFile, Long nOffset, Long nAttr, Variant Values)
Parameters:
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 writing into the binary file (e.g. 10 means writing into 10th byte of the file).
If the value is -1, then offset is set to the end of the file. The parameter has the importance only for nAttr=1, otherwise nOffset=0 must be set.
nAttr(Long) Bit attribute. It can be 0 or a sum of the following applicable values.
1 - If the file already exists, then its content will be overwritten from the offset (see the nOffset parameter).
If the value 1 is not set, then the entire content of the file will be cleared before writing.
2 - Value of the String type (text string) is stored without the string end character.
If the 2 value is not set, then the string is stored into the file and one more byte with the value 0 is added (the string end character).
Values(Variant) Variable of the Array type whose items are stored.
Return value:
Returns the number of written bytes (Caution: not the number of items!). If an error occurred, then the method returns the negative number.
Note:
Individual array items are stored according to their data type as follows:
Data type: Number of stored bytes into 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)


This method is not functional in Web panels.
Example:
Writing the array of 4 items into the file.
1st item is of the Long type and thus 4 bytes are written.
2nd item is of the String type and thus 5 bytes are written (including ending 0),
3rd item is of the Double type and thus 8 bytes are written and
4th item is of the Byte type and thus only one byte is written.
Thus altogether 4+5+8+1 bytes are written into the file.
VBScriptSelect and copy to clipboard

Dim Length, Val

Val = Pm.Array1(CLng(1), "test", CDbl(3.14), true)
Length = Pm.FileBinaryWrite("#data:File.bin", 0, 0, Val)

If Length = 4+5+8+1 Then
Pm.Debug "Data have successfully been written"
Else
Pm.Debug "Writing data failed! Length=" & Length
End If
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- FileBinaryWrite
 
 
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r.o.