Add element to dynamically created global list


I need in one of my projects to add elements to a list I'm dynamically creating.
I've created a new variable (as recommended here) and set it to an empty list.
But everytime I try to add an element to the list, it throws an error saying "Inside Error: Expecting list but getting text".
Is it possible to do what I'd like to do?
If yes, any idea how?

Here is what I'm doing:
Snap! Unit script pic
Creating (local variable with) a name for my new global variable ("Test Report ...")
Creating a local variable holding the timestamp of the script start.
Putting my global variable ("Test Report") as an empty list.
Adding the difference between timestamps to the list. (Error here)


One problem is that you're giving that RUN two "with inputs" slots, the first empty. I think you meant to have only one of them. (Or, no, maybe that JOIN expression used to be in the empty one and both inputs to ADD used to be empty?) But the other problem is that what will be substituted into the empty slot in the ADD is the name of the list (the value of testRapportName), not the actual list. Use this:

Here's the code to copy-paste:

if ((typeof name) != "string") {
    throw new Error("name isn't a string: " + name);
    var frame = this.variables.silentFind(name),
    if (frame) {
        value = frame.vars[name].value;
        return (value === 0 ? 0
                : value === false ? false
                        : value === '' ? ''
                            : value || 0); // don't return null
    if (typeof name === 'number') {
        // empty input with a Binding-ID called without an argument
        return '';
    throw new Error(
        localize('a variable of name \'')
            + name
            + localize('\'\ndoes not exist in this context')

It doesn't work for script variables, just the kinds you can make with the variables library.

Ok, thank you.

I didn't really know how the "call" block would substitute the inputs of the "add" block. (If it only filled empty slots with additional inputs provided or every input provided was assigned to a slot in the call block).

Also, I forgot you just couldn't add to a list by providing its name and that it has to be a reference to the list.

Anyway, I've found an easier solution (by creating a temporary script variable and then setting the global variable at the end of the script).

Thank you for your answer :wink:

If the called function expects exactly one input, then the value in the CALL will fill every empty slot.

If the called function expects more than one input, then the number of values in the CALL must equal the number of inputs expected, and the values are substituted into the slots from left to right.