Array push function and virtual ressources

Hi,
I created a virtual ressource (an array) :


I added a value in the array with the “push” function :
"
var pileMessages = Datahub.read(’/virtual/pileMessages/value’, 0);
var arrayPileMessages = pileMessages.value;
var x = arrayPileMessages.push([30]);
"
But I have a error message :
“TypeError, Expected a function”

Thanks for your help

Romuald

Hi Romuald,

It seems that your VR is defined as a String

If you create your VR as a JSON type, and directly set it to be : [1,2,3]

function(event) {

var arrayPileMessages=Datahub.read("/virtual/array/value",0).value;

console.log(arrayPileMessages)

var x = arrayPileMessages.push(30);

console.log(arrayPileMessages)

}

Console logs return:

[1,2,3]

and then

[1,2,3,30]