Blob function

Started by Mohamed Boubekri, Sep 09, 2023, 11:37 PM

Previous topic - Next topic

Mohamed Boubekri

Hey everyone, i want to create something like this:
local dataBlob = blob(512);
dataBlob.writestring(vehicle.Pos.x);
Message("here is your x: "+dataBlob.readblob(512));
But i get error in the second line, "data types string expected float/integer"
How i can put vehicle pos in blob ? if blob take only integer/float values, then how i can do the above example
in Array ?
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

habi

will that work datablob.writenstring because that is not listed in squirrel's reference. You may see it http://squirrel-lang.org/squirreldoc/stdlib/stdbloblib.html
To write float,
datablob.writen(675.522, 'f');

another example:
for(local i=0;i<str.len();i++)datablob.writen(str[i], 'c');
//this will copy the string str to datablob.


Mohamed Boubekri

Quote from: habi on Sep 10, 2023, 07:04 AMwill that work datablob.writenstring because that is not listed in squirrel's reference.
https://developer.electricimp.com/squirrel/blob/writestring
Quote from: habi on Sep 10, 2023, 07:04 AMTo write float,
I need to write a string, if there is no way to insert string into blob, then how i can insert string into array ?
local Array = [0];
Array.insert(0, "+vehicle.Pos.x+");
Message("here is your x: "+Array.find(0));
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

Mohamed Boubekri

#3
local Array=[0,1];
Array.insert(0,vehicle.Pos.x), Array.insert(1,vehicle.Pos.y);
Message("here is your x: "+Array[0]+" and your y: "+Array[1]);
Its done now, anyway thanks.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].