Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

CR1000 & binary file


VVitolo Jan 13, 2016 06:53 PM

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


JDavis Jan 14, 2016 05:12 PM

You need to open the file in "wb" (write binary) mode. 


VVitolo Jan 14, 2016 10:51 PM

Thanks a lot

I will try this option and post the result

Best regards


VVitolo Jan 18, 2016 05:19 PM


Thank you, It has tested the proposed solution and working properly.

Best regards

Log in or register to post/reply in the forum.