No, DATA is for holding constant data, it can't be used for data that changes!In BASIC, binary data is typically stored using the DATA keyword.
Indeed, C's strings are not suitable for binary data, but BASIC's strings are! That C's strings cannot hold binary data is not really a "shortcoming" because C has other methods of storing and manipulating binary data, for example a memory block allocated with malloc().I haven't studied the string structure in PureBasic yet. But I remember for sure that in C++ strings end with a null byte. Then this is a shortcoming of C++ too.
BASIC is a very different language from C or C++ and one of the distinguishing features of BASIC is that its strings are binary-data compatible. One key advantage is that the string is managed, you can't accidentally write past the end of a string in BASIC and corrupt memory, whereas in C you can very easily do that.
For example suppose one wants to read 1 Kilobyte of binary data from a file, In BBC BASIC one would do that as follows:
Code:
bin$ = GET$#file BY 1024Code:
bin%% = PTR(bin$)Code:
found% = INSTR(bin$, CHR$0 + CHR$0) IF found% THEN PRINT "Data contains 0x00 0x00 at offset "; found%-1Statistics: Posted by RichardRussell — Wed Apr 02, 2025 3:14 pm