Persistent variables can be used inside prelude expressions like any other variable.

Persistent variables cannot appear on the left-hand side of a declaration in the prelude. 

For historical reasons, if the persistent variable does not exist before it is used, the default value is 0. 

This means that the isnull() operator, for example, is never true for an entity variable.

Examples

The following declaration would add 3 to the value stored in the entity counter ent:fizz, storing the result in x:

pre {
  x = ent:fizz + 3
}

Deprecated Operators

The following are deprecated and should not be used. 

KRL includes special built-in functions for accessing individual places in a trail. These are deprecated and should not be used

pre {
  x = history 1 ent:another_trail;
}
pre {
  x = current ent:another_trail;
}