The append Command

The append command adds a value to the end of a string, array, or HTML element. If you don't specify a target, it writes to the standard result variable.

The behavior depends on the target type:

Examples

Append to a string

set fullName to "John"
append " Connor" to fullName
-- fullName == "John Connnor"

Append to an array

set resultArray to []
append 1 to resultArray
append 2 to resultArray
append 3 to resultArray
-- resultArray == [1,2,3]

Append to an HTML Element

append "<i>More HTML here</i>" to #myDIV

Use append to collect content

If no target variable is provided, append writes to the standard result variable by default. This can help you write more compact code — but be careful, many other commands also write to result (or it), which can overwrite your work.

set result to "<div>"
repeat for person in people
    append `
        <div id="${person.id}">
            <div class="icon"><img src="${person.iconURL}"></div>
            <div class="label">${person.firstName} ${person.lastName}</div>
        </div>
    `
end
append "</div>"
put it into #people

Syntax

append <expression> [to <string> | <array> | <element>]