docs.roxen.comView this page in a printer friendly mode
DocsRoxenWebServer 5.4Web Developer ManualVariable Tags
Copyright © 2018, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com

   

<append>
<copy-scope>
<dec>
<define>
<elements>
<inc>
<insert>
<insert cached-href>
<insert file>
<insert href>
<insert realfile>
<insert scopes>
<insert variable>
<insert variables>
<json-format>
<json-parse>
<range>
<roxen-automatic-charset-variable>
<scope>
<set>
<sprintf>
<sscanf>
<undefine>
<unset>
<use>
<value>
<vform>

<append/> or <append></append>

Provided by module: Tags: RXML tags

Appends a value to a variable.

If the variable has a value of a sequential type (i.e. string, array or mapping), then the new value is converted to that type and appended. Otherwise both values are promoted to arrays and concatenated to one array.

<set variable="var.x">a,b</set> <append variable="var.x">,c</append> &var.x;
String result: "a,b,c"
<set variable="var.x" split=",">a,b</set> <append variable="var.x">c</append> &var.x;
Array result: ({"a", "b", "c"})
<set variable="var.x" type="int">1</set> <append variable="var.x" type="int">2</append> &var.x;
Array result: ({1, 2})

It is not an error if the variable doesn't have any value already. In that case the new value is simply assigned to the variable, but it is still promoted to an array if necessary, as described above.

<append variable="var.x" type="int">1</append> &var.x;
Array result: ({1})

Note that strings are sequential but numbers are not. It is therefore crucial to not mix them up, especially since it is fairly common that numbers actually are in string form. C.f:

<set variable="var.x" value="1"/> <append variable="var.x" type="int">2</append> &var.x;
String result: "12"
<set variable="var.x" type="int" value="1"/> <append variable="var.x" type="int">2</append> &var.x;
Array result: ({1, 2})

To avoid confusion, use "type" attributes liberally.

Compatibility note: Before 5.0 this tag had a bit quirky behavior in various corner cases of its type handling. That behavior is retained if the compatibility level is less than 5.0.


Attributes

variable="string"

The name of the variable to set.


value="string"

A value to append. This is an alternative to specifying the value in the content, and the content must be empty if this is used.

The difference is that the value always is parsed as text here. Even if a type is specified with the "type" attribute this is still parsed as text, and then converted to that type.


from="string"

Get the value to append from this variable. The content must be empty if this is used.


expr="string"

An expression that gets evaluated to produce the value for the variable. See the "expr" attribute in the <set> tag for details. The content must be empty if this is used.


type="type"

The type of the value. If the value is taken from the content then this is the context type while evaluating it. If "value", "from" or "expr" is used then the value is converted to this type. Defaults to "any".