lookup

A lookup defines constants to be substituted inside of other tag attributes or used in ogScript blocks.  Lookups contain “entry” tags to define key/value pairs. Constants defined in a parent context can be referenced in a child context.  If a key from the parent context is re-defined in a child context, the re-defined value will take precedence in the child’s scope.

Global lookup tags should usually be placed within an api tag.

Syntax

<lookup id="id-string" scope="scope">

<entry key="key">value</entry>

<entry key="key">value</entry>

. . .

</lookup>

Attributes

Attribute

Values

Restrictions

Description

scope

private

public

window

If “private”, the lookup must define the id attribute.

By default, all key/value pairs are added to a general lookup table.  The lookup table in any context is the concatenation of all parent lookup tables and sibling lookup tables.

If the scope is set to “private”, the key/value pairs can only be referenced using the lookup table’s ID.

id

string

 

If defined, key/value pairs for this lookup can be referenced in ogScript using “ogscript.getPrivateString(‘[id]’, ‘[key]’);”

Or substitute inside of other attributes with %const[‘id’][‘key’]%

code

true

false

 

Must be set true if the lookup value contains executable script.

multiline

true

false

 

Must be set true if lookup value contains multi-line strings.

Default values shown in bold.

Example

The following tag creates a public lookup

<lookup>

<entry key="breakfast">Bacon and Eggs</entry>

<entry key="lunch">BLT</entry>

<entry key="dinner">Bacon explosion</entry>

<entry key="snack">Bacon-maple donut</entry>

</lookup>

 

The following code returns the stringBLT.

var currentMeal = ogscript.getString('lunch');

The following tag creates a private scope lookup

<lookup id="family" scope="private">

<entry key="father">Homer Simpson</entry>

<entry key="son">Bart Simpson</entry>

<entry key="mother">Marge Bouvier-Simpson</entry>

<entry key="daughter">Lisa</entry>

<entry key="baby">Magaggie</entry>

</lookup>

The following code would return the stringHomer Simpson.

var name = ogscript.getPrivateString('family', 'father');

The following tag creates a block of code lookup:

<lookup code="true" id="GlobalScripts" multiline="true">

<entry key="UpdateTimer">

if (params.getValue('Update_Automatically', 0) == 1)

{

   ogscript.getTimerManager().getTimer('UpdateTimer').startTimer(false);

}

else

{

   ogscript.getTimerManager().getTimer('UpdateTimer').stopTimer(false);

}

</entry>

</lookup>


 

The following is an example of instancing the code defined in the above lookup:

<ogscript handles="onload">%const['GlobalScripts']['UpdateTimer']%</ogscript>