2. Variables and Types
WEMscript is a statically strongly typed language. Before you can use a variable, it must be declared using the var
statement, with a specific type either explicitly set or inferred from its value. Every variable is prefixed with an @
symbol. A variable's value is unknown
when no value has been assigned yet.
The following types are available in WEMscript: boolean
, concept
, conceptset
, datetime
, duration
, file
, list
, number
, richtext
, and text
. These types correspond to those found in the data model of a WEM project. Additionally, there is a one-dimensional array type array<T>
, where T
can be any of the previously mentioned primitive types, except for array
.
Properties
There is a distinction between variables and widget properties: properties are not assignable. They require a postback to update their values.
Boolean
A boolean type can be set using the keywords true
, false
, unknownboolean
, or a WEM expression that returns a boolean type.
Concept
The concept is a special type that can only be assigned from an existing concept variable or concept property. This is because the context (concept children and siblings) is known within a WEM project, but it is unknown within a WEM widget. For example, let's assume we have a concept property named Color
.
You may be wondering how to set a concept property data field; this topic is beyond the scope of this chapter and will be explained later.
Concept set
Soon
Datetime
Soon
Duration
Soon
File
Soon
List
Soon
Number
Soon
Richtext
Soon
Text
Soon
Arrays
Last updated
Was this helpful?