Hi All,
Having an issue with a setup involving a CR1000 and binary file.
In the next code, we have an string of binary data ('1010100....10111') and finally, we want to save that data in a binary file.
BinToInt function convert the binary data in a integer value (0..255), Ex.: '11111111' --> CHR(255).
fDatalogger= "CPU: test_data_bin.dat"
nFile = FileOpen(fDatalogger,"w",0)
'Save data, converting from binary to int
For i=1 To Len(sStringBin) Step 8
sOct=Mid(sStringBin,i,8)
code= BinToInt(sOct)
bytesFichero = FileWrite(nFile, CHR(code), 1)
Next
FileClose(nFile)
Here it is the issue:
Every time we need to put a integer value 10, CHR(10), in the final file saved we get an CHR(13)+CHR(10) pair.
Is there any way to avoid this issue?
Best regards
Victor
You need to open the file in "wb" (write binary) mode.
Thanks a lot
I will try this option and post the result
Best regards
Thank you, It has tested the proposed solution and working properly.
Best regards