Hi Guys - I frequently use the .substr with command values and it works well. Now I need to separate values by a comma deliminated list passed into SambaPOS via a message.
My command value that comes in is as such: typeCreate,field1,field2,field3,field4
In my Rule for my action to be fired, I’ve added these to try to deliminate the above fields:
I think most likely it failed because of square bracket [1], lot of chances parsing error with square bracket. Why not just use call function for substr?
Just make generic something like this (not test)
function getArrayValue(array,index) {
array=array.split(",");
return array[index]
}
That may be slightly beyond my understanding of the rules/action system in SambaPOS which do appreciate and continue learning. It’s funny I can write plenty of node.js but not handle a few simple functions in SambaPOS.
Basically I actually tried to pass the whole thing to a call function first and then do the split there but it failed, I had this as an example:
{CALL:processor.NewInput('[:Command]')}
and then
function NewInput(dataIn) {
var returnMe = dataIn.split(",")[1];
return returnMe;
}