Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
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
Solved! Go to Solution.
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
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.