cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Substring not working

AT_10337619
7-Bedrock

Substring not working

I am trying to extract the data from big string (ASCII)  40 char long into 10 word

following code does not work.

I am trying to test service in Thing Template

 

var rawString = me.vbsMachineRawData;
var rawHexWord = [];
var j = 0;

for (var i = 0; 40 ; 4) {
rawHexWord[j] = rawString.substring(i, (i + 4));
j = j + 2;
}

error executing service

 

1 ACCEPTED SOLUTION

Accepted Solutions

var rawString = '1111111111111111111111111111111111111111';
var rawHexWord = [];
for (var i = 0; i < 40 ; ) {
    rawHexWord.push( rawString.substring(i, (i + 4)));
    i = i + 4;
}
result = rawHexWord; // Result will be 
 - ["1111","1111","1111","1111","1111","1111","1111","1111","1111","1111"]

Try above snippet

View solution in original post

2 REPLIES 2

var rawString = '1111111111111111111111111111111111111111';
var rawHexWord = [];
for (var i = 0; i < 40 ; ) {
    rawHexWord.push( rawString.substring(i, (i + 4)));
    i = i + 4;
}
result = rawHexWord; // Result will be 
 - ["1111","1111","1111","1111","1111","1111","1111","1111","1111","1111"]

Try above snippet

Satish,

thanks. That works.

 

Announcements