Problem saving to Blob from Agent

The agent is sending the IMP a string similar to this: V02000:B,V02001:B,V02000:D

I need to remove the V, the : from each and save the 2000 in 1 blob and the letter B in a different blobs. When I do the parsing, I can user server.log to see the result of the letter B being parsed out, then I write it to the blob, then later down then line when I read the blob, instead of the letter B, I get the value 16…???

agent.on(“vmem”, function(value) { //receive data from agent

local v = split(value.tostring(),",");
numvmems = 0;
local a = 0;
for (a = 0; a <= 3 ; a++){
        local j = split(v[a].tostring(),":");
        server.log(j[1]);//Here server logs the letter B or D or R
        local k = split(j[0].tostring(),"V");
        local ak = k[0];
        local vmem = (ak[0] & 7)<<12;
        vmem += (ak[1] & 7)<<9;
        vmem += (ak[2] & 7)<<6;
        vmem += (ak[3] & 7)<<3;
        vmem += (ak[4] & 7);
    //    break;

gotdlog1 = 1;,'b');
for (a = 0; a < numvmems; a++){
local tt = " ";,'b');
for (a = 0; a < numvmems; a++){
    tt = dlog1t.readn('b');//HERE server logs 16  Should be the letter B or D or R


You’re trying to write a string as a byte, which is going to give you odd behaviour.

Basically, when you split v[a] you get an array of strings. The second entry in the array (j[1]) only has a single character, but it is still a string, and not a single character. You need to either index the first character of that string, or use writestring instead of writen:

local j = split(v[a].tostring(),":"); dlog1t.writen(j[1],'b');

Need to be changed to either:

local j = split(v[a].tostring(),":"); dlog1t.writen(j[1][0],'b'); // write the first character of the second part of the split string


local j = split(v[a].tostring(),":"); dlog1t.writestring(j[1]); // write the entire part of the split string

You also need to modify how you display you’re resultant string a little bit. If you want to write out the result as a single string (“BBD” in this case) you can just do:


If you want to display each character individually, you’ll need to convert the values from a number, to a character - you can do this with format:

server.log(format("%c", dlog1t[a]));

Hopefully that all makes sense - let me know if you have questions!