Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Specialize warning for old engine

Persistents in condition statements are accessed in the same way as in the prelude.

Warning

For In the classic KRE, 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 in the old engine.

Examples

The following action will fire when the persistent variable ent:archive_pages is greater than 3:

Code Block
languagejavascript
themeConfluencelanguagejavascript
if ent:archive_pages > 3 then 
notify(...)

...

Persistent flags and counters can also be tested with an associated timeframe. For example, the following action will fire when persistent variable ent:archive_pages is greater than 3 and the last time it as set was within the last two hours:

Code Block
languagejavascript
themeConfluence
languagejavascript
if ent:archive_pages > 3 within 2 hours then
notify(...) 

The syntax of timeframe-limited predicates is as follows:

Code Block
languagejavascript
themeConfluencelanguagejavascript
<pvar> (<= | >= | < | > | == | !=) <expr> 
   within <expr> (weeks| days| hours | minutes| seconds)

...

Persistent trails can be tested using the seen predicate. There are two forms. The first form asks whether a regular expression has been seen within an optional timeframe (specified exactly as above). So, you can say:

Code Block
language
languagejavascript
themeConfluencejavascript
if seen re#/archive/2006# in ent:my_trail then
  notify(...) 

or

Code Block
language
languagejavascript
themeConfluencejavascript
if seen re#/archive/2006# in ent:my_trail within 3 days then
  notify(...) 

The second form of special predicates for trails allows for checking whether a match of one regular expression appears before an item matched by another. This example would fire the action when a place matching the regular expression re#/archive/2006# was put on the trail before a place matching the regular expression re#/archive/2007#.

Code Block
languagejavascript
themeConfluencelanguagejavascript
if seen re#/archive/2006# before re#/archive/2007# in ent:my_trail then 
  notify(...) 

...