An archive of community.esquilo.io as of Saturday January 26, 2019.

ERPC with Array

triste

Hi,
Is it possible to return values of Array from NUT using ERPC call on HTML ?

Thanks,
triste

Scott_Shumate

Absolutely.

For example, this nut returns an array:

function matrix(val)
{
    return [ val, 2 * val, 3 * val];
}

And this JavaScript ERPC call uses the result:

erpc("matrix", 7, function(array) {
    for (var i = 0; i < array.length; i++) {
        console.log(i + " = + array[i]);
    }
});

You can even nest other arrays or objects in the array.