Always remember that ALL in computer is just a sequence of bytes.
String are sequences of bytes, numbers (any type) are sequences of bytes.
What differentiate one variable to the other is the meaning we give to them.
That said, you can take advantage of thinBasic binary converting functions called MKxx (from numeric to string) and CVxx (from strings to numeric)
There is just one trick to keep into consideration: for all numeric types we can know their length so reading them back is not a problem (bytes are one byte, long are 4 bytes, ...) but in order to read back dynamic strings, you need to store the original string length. This will allow you to read back the string knowing its length.
Your code can be something like the following but there can be many other ways to store binary info into files depending how you want your data organised into the file.
Uses "file"
Local i As Long
Local myByte(10) As Byte
Local myLong(10) As Long
Local myDouble(10) As Double
Local myString(10) As String
'---Open file for writing in BINARY mode
Long fNum = FILE_Open (APP_SourcePath & "myFile.dat", "BINARY")
For i = 1 To 10
'---Write the binay for of a long
FILE_Put(fNum, MKL$(myLong(i)))
'---Write the binay for of a double
FILE_Put(fNum, MKD$(myDouble(i)))
Next
For i = 1 To 10
'---Write the binay for of a byte
FILE_Put(fNum, MKBYT$(mybyte(i)))
'---For strings, in order to be able to read back, you need to store also string lenght
'---So here we will write a binary long containing the string lenght
'---when we will read it back we will know the len of the subsequent string to read
FILE_Put(fNum, MKL$(Len(myString(i))))
FILE_Put(fNum, myString(i))
Next
FILE_Close(fNum)
Bookmarks