Table of Contents

Tokens

A token is basically a variable that you can store data in or retrieve data from at runtime in your guiDesigner projects. A token has a name and a value.

Token Naming

Suggested Syntax: [name]

A token can be named anything you like, but we suggest you follow the syntax above, including the square brackets in your token names. By doing this, it makes it easier to see where your token is actually being used within command values, etc.

Types of Tokens

There are three types of tokens:

  1. Global Tokens
  2. Predefined Tokens
  3. Object Tokens

Global Tokens

As the name suggests, a global token is available to be used globally throughout your guiDesigner project.
Global tokens are defined in Project Properties > Global Token Manager.
A global token is the only type of token that can be set to persist its data across launches of iViewer, so you can store state data and retrieve it again the next time iViewer is opened.

Using our JavaScript API, you could persist a JSON string across sessions and restore the JSON object on each launch, allowing you to theoretically store any dynamic data across launches.

NOTE: Data is not persisted across GUI reloads. Each time the GUI is reloaded (when Reload GUI Layout is enabled in iViewer Settings), global token values will be reset to their default value (or blank if no value is defined in the Global Token Manager).

Predefined Tokens

There are a number of tokens that are predefined for you in certain cases, depending where the token is being used.

Globally defined

Attached to every GUI object

Attached to all Objects within Lists

Any object within a list (button, slider, image, etc) will automatically have the following tokens attached to it:

Attached to gesture actions

See the gesture wiki entry for details on the predefined tokens available for gesture actions.

Attached to sliders

Attached to input fields

Object Tokens

Tokens can be assigned to any object via its join number at runtime. These tokens can be set and retrieved at runtime only. For example, you can store the state state of something in a token applied to a button. Then when that button is pressed, use the token value as part of the command that the button sends, or even use the token within a math expression or JavaScript function that the button calls.

Using Tokens

Tokens can be used throughout your guiDesigner project in a number of ways: