Moving string to array

I’m working on this issue: https://github.com/electricimp/reference/issues/8 to try to get the wireless bootloader working. I have re-written the HEX parser, but I am a complete noob when it comes to squirrel.

I’d like to move a string into an array:

`
//Move 128 bytes from big array into a temp string, linedata
local linedata = blob(128);
for(local x = 0 ; x < 128 ; x++)
linedata.writen(bigArray[x], ‘i’);

this_line.data <- linedata.readblob(0); //Push linedata to the line array
hexData.push(this_line); //Push this line into the overall array

`

linedata is getting loaded correctly from bigArray but I can’t seem to figure out how to move linedata into the other array called this_data.

I come from the wonderful world of C. Where can I read more about <-'s, and ‘this_line.data’ type data structures? Again, sorry for my simpleton question but finding any help via google and ‘squirrel’ is a frustrating dead end.

I presume you’re trying to write bytes to linedata, in which case it should be ‘b’ (byte) vs ‘i’ (32 bit int).

At the point when linedata is written, your “file pointer” is at the end, ready for more data to be written. You should do linedata.seek(0) to return the pointer to the beginning before reading it.

Then, to read 128 bytes from the blob you should use readblob(128). The parameter is the number of bytes to read.