How to assign a binary data

Hi
For Hex data we write a = 0xaf;
in C for assigning binary data we write a = 0b10101111;
how do i do it in squirrel?

You cannot assign binary data in Squirrel (as far as I know at least… I would be happy to be wrong).

You’re spot on about the hex, you can also declare a longer hex string in the following way:

//0xDEADBEEF x = "\\xDE\\xAD\\xBE\\xEF";

Have similar question, but see no answer was given… does anyone have a handy utility function for assigning binary.

I was going to try using blobs, but cannot figure out how to “insert” the binary value 10101111 manually into a blob. Do I use blob.writeblob(blob) or blob.writen(value, const)

Once I inserted into, if I want to convert and see the byte value I simply use my_data_blob.readn(‘b’)

Any pointers.

@gerriko - you’ve got the idea.

Take a look at our blob documentation (specifically, writen, writeblob, and writestring)

To insert 10101111 (0xAF) you would do a:

b <- blob(); b.writen("\\xAF", 'b');