[Rules] Complex flowvar definition in LUA

Hello everyone,

Actualy, I have this lua script which is working well (This is an example of course):

function init(args)
    local needs = {};
    needs["payload"] = tostring(true);
    needs["flowvar"] = {
        "User",
        "Name"
    };
    return needs;
end

function match(args)

    local flowvar_user = ScFlowvarGet(0);
    local my_value = "...";
    ScFlowvarSet(0, my_value, #my_value);
...
    return 1;
end

In fact, the result will be something like that:

"flowvar": [
    { "User": "..." },
    { "Name": "..." }
]

My problem is if the script is launched 2 times (or more) in the same flow, the last execution will erase and replace the previous one.
Do you know if it’s possible to get a result like that? (With infinite incrementation):

"flowvar": [
    0:{
        { "User": "..." },
        { "Name": "..." }
    },
    1:{
        { "User": "..." },
        { "Name": "..." }
    },
    ...
]

Thank you in advance,
Best regards,
Juquod

The best work around may be to increment the User with a custom-defined separator…

like

"flowvar": [
    { "User": "User1|User2" },
    { "Name": "Name1|Name2" }
]

Hello Philippe,

Thank you for your answer.

In fact, it could work. However, the problem will be the visibility. When you have 2, 3 data, no problem. However if you begin to get 10, 20 data and you are search for correspondance, that begin to be impossible.

"flowvar": [
    { "User": "User|User||User|User|User|User|User||User||User" },
    { "Name": "Name||Name|Name|Name|Name|Name||Name|Name|" }
]

Here, which user has a name? Which name is associated to a user?
And of course, the real data to parse are not too simple…

That’s why i’m searching a solution to keep the data easy to read.

Regards,
Juquod