PLUG'N SCRIPT
rapid plugin development
Tutorial
DSP
KUIML
How-to
Scripts
  • Overview
  • Tutorial
  • Reference
Layout and positioning
  • CELL
  • TABLE
Language basics
  • SKIN
  • DUMMY
  • INCLUDE
  • INCLUDE_ONCE
  • DEFINE
  • UNDEFINE
  • VARIABLE
  • LOCAL_VARIABLE
  • TEMPLATE
  • TEMPLATE_INNER_CONTENT
  • TEMPLATE_UNLOAD
  • REPEAT
Text widgets
  • TEXT
  • TEXT_FIELD
  • TEXT_EDIT_BOX
  • TOOLTIP
  • PARAM_TEXT
  • PARAM_TEXT_CONTROL
  • PARAM_TEXT_EDIT_BOX
  • PARAM_TOOLTIP
Image widgets
  • IMAGE
  • IMAGE_ACTION_BUTTON
  • IMAGE_GROUP_BOX
  • IMAGE_PARAM_BUTTON
  • IMAGE_PARAM_KNOB
  • IMAGE_PARAM_LINEAR_METER
  • IMAGE_PARAM_MENU_BUTTON
  • IMAGE_PARAM_METER
  • IMAGE_PARAM_SLIDER
  • IMAGE_PARAM_TOGGLE_SWITCH
  • XYZ_IMAGE_PARAM_JOYSTICK
Invisible controls
  • INVISIBLE_ACTION_BUTTON
  • INVISIBLE_PARAM_BUTTON
  • INVISIBLE_PARAM_KNOB
  • INVISIBLE_PARAM_MENU_BUTTON
  • INVISIBLE_PARAM_SLIDER
  • INVISIBLE_PARAM_TOGGLE_SWITCH
  • XY_PARAM_PAD
  • XY_ZOOM_SELECT_PAD
  • XYZ_PARAM_SCRATCH_PAD
  • XYZ_PARAM_CLICK_PAD
Drawing, curves & 3D
  • CANVAS
    • Graphics API
  • svg
  • CURVE_GRAPH
  • XY_CURVES_GRAPH
  • GRID
  • RULER
  • COLOR_SCALE
  • VIEW_3D
  • COLOR_SURFACE_3D
  • GRID_3D
  • GL_OBJECT_3D
    • OpenGL Cheat Sheet
  • SURFACE_COLORMAP_2DPLOT
Miscellaneous
  • SCRIPT
  • WIDGET
  • KUIML_WIDGET
  • POPUP_MENU
  • MENU_ITEM
  • MENU_SEPARATOR
  • FILE_SELECT_MENU
  • SYSTEM_ACTION_BUTTON
  • SYSTEM_PARAM_CHECKBOX
  • SYSTEM_PARAM_DROPDOWN_LIST
  • WINDOW
  • LOAD_FONT
Data model
  • STRING
  • PARAM
  • FORMULA_PARAM
  • PARAM_ANIMATOR
  • ACTION
    • Built-in action types
  • TIMER
  • ACTION_TRIGGER
  • CURVE
  • FORMULA_CURVE
  • CURVE_FROM_PARAM_OVER_TIME
  • SURFACE
  • FORMULA_SURFACE
  • SURFACE_FROM_CURVE_OVER_TIME
  • GROUP
Links and commands
  • PARAM_LINK
  • PARAM_MULTI_LINK
  • PARAM_CONNECTION
  • PARAM_TO_STRING_LINK
  • STRING_LINK
  • STRING_MULTI_LINK
  • CURVE_LINK
  • CURVE_MULTI_LINK
  • SURFACE_LINK
  • REQUIRED_OBJECTS
  • EXPOSED_OBJECTS
  • PERSISTENT_OBJECTS
Common attrubutes
  • For all elements
  • Widgets
  • Param Widgets
  • Param Controls
  • Param Info Viewers
  • Text Widgets
  • Surface Viewers
  • Curve Viewers
  • Images
  • 3D Objects
Additional information
  • All attributes
  • Attribute types
  • Cursors
  • Math formulas
  • Scripting
    • Built-in addons
  • User experience
  • Errors and solutions
  • Built-in variables
  • Runtime model
  • Parameters mapping
  • Script converter
  • LetiMix
KUIMLReferenceVARIABLE
September 02, 2025

VARIABLE

This element ca be used to define custom values to be reused later in the attributes of other elements, in order to avoid repeating several times the same value. It makes it easier to change the value once rather than everywhere in the code.

Note: to avoid conflicts with Predefined Variables, variables starting and ending with '_' are reserved to the KUIML engine.

Attributes brief detailed show all inherited

Name DescriptionDefault
idid of the variableThis is the name you will use everywhere in the skin and it will be replaced by the value attributeempty
valuevalue of the variableThis is the value that will replace the '$id$' string everywhere in the skinempty
formulaThe formula can reference other static variables that have been defined previously. The result of the formula is stored in the variable at the declaration of the variable and is not updated later, even if other variables it depends on are changedThis attributes overrides the "value" attribute when setempty
scriptScript that returns a string that defines the new value of the variable. It can use functions that have been defined in the build_time_script_include file (but not other runtime function defined in runtime scripts). It can also refer to build time variables that have been defined beforeThis attributes overrides the "value" and "formula" attribute when set. It is currently experimental.empty
overrideoverride previously defined valueSetting this to true removes the warning that is normally thrown when a variable is defined twicefalse
Name Value type Default Description Comment
idelement idemptyid of the variableThis is the name you will use everywhere in the skin and it will be replaced by the value attribute
valuestringemptyvalue of the variableThis is the value that will replace the '$id$' string everywhere in the skin
formulaMath FormulaemptyThe formula can reference other static variables that have been defined previously. The result of the formula is stored in the variable at the declaration of the variable and is not updated later, even if other variables it depends on are changedThis attributes overrides the "value" attribute when set
scriptscript returning a stringemptyScript that returns a string that defines the new value of the variable. It can use functions that have been defined in the build_time_script_include file (but not other runtime function defined in runtime scripts). It can also refer to build time variables that have been defined beforeThis attributes overrides the "value" and "formula" attribute when set. It is currently experimental.
overridebooleanfalseoverride previously defined valueSetting this to true removes the warning that is normally thrown when a variable is defined twice

Syntax

First declare a variable as shown here:

  1. <VARIABLE id="my_variable" value="hello world!" />

Once this variable has been declared, writing the following

  1. <TEXT value="$my_variable$"/>

is equivalent to writing:

  1. <TEXT value="hello world!"/>

The same example, with script syntax (note that all special characters in script have to be escaped):

  1. <VARIABLE id="my_variable" script="return &quot;hello world!&quot;" />

Advanced usage

The possibility to "override" variables is useful in complicated layouts and templates. If you plan to use overriden variables often, then you can add defines like this to shorten the code (already defined in LM Skin):

  1. <DEFINE>
  2. <VAR base_type="VARIABLE" override="true" />
  3. <LV base_type="LOCAL_VARIABLE" override="true" />
  4. </DEFINE>

Now you can write something like this:

  1. <VAR id="N" value="0" />
  2. <VAR id="REVERSED" value="" />
  3. <REPEAT index_list="Mode A;Mode B;Mode C">
  4. <TEXT value="$N$: $index$" />
  5. <VAR id="N" formula="$N$+1" />
  6. <VAR id="REVERSED" value="$index$;$REVERSED$" />
  7. </REPEAT>
  8. <TEXT value="$REVERSED$" />

The output should look like this:

You could use "LV" (LOCAL_VARIABLEs) instead, if you don't need these values later (for example a temporary variable inside a TEMPLATE).

Build-time scripts

If you need to do some complicated operations while build-time (usually related to strings) you can use scripts inside VARIABLES, like this:

  1. <VARIABLE id="IS_WINDOWS" script="if (&quot;$_SYSTEM_TYPE_$&quot; == &quot;Windows&quot;) return &quot;1&quot;; else return &quot;0&quot;;" />

  2. <REPEAT count="$IS_WINDOWS$">
  3. <TEXT value="We're on Windows" />
  4. </REPEAT>

  5. <REPEAT count="!$IS_WINDOWS$">
  6. <TEXT value="We're on Mac" />
  7. </REPEAT>

Note that we can make build-time scripts a little more readable if we use single-quotes (which is not usual) and thus avoid escaping double quotes.

  1. // using single quotes
  2. <VARIABLE id="IS_WINDOWS" script='if ("$_SYSTEM_TYPE_$"=="Windows") return "1"; else return "0";' />

  3. // even shorter
  4. <VARIABLE id="IS_WINDOWS" script='return ("$_SYSTEM_TYPE_$"=="Windows") ? "1" : "0"' />

Check if VARIABLE contains a substring:

  1. <VAR id="IS_BCA_PLUGIN" script="if (&quot;$PLUGIN_NAME$&quot;.findFirst(&quot;Blue Cat&quot;)>-1) return &quot;1&quot;; else return &quot;0&quot;;" />

  2. <!-- display the result -->
  3. <TEXT value="IS_BCA_PLUGIN: $IS_BCA_PLUGIN$" />
  4. <REPEAT count="$IS_BCA_PLUGIN$">
  5. <TEXT value="This is a Blue Cat Audio plugin: $PLUGIN_NAME$" />
  6. </REPEAT>

We could rewrite it a little shorter using single quotes and ternary operator:

  1. <VAR id="IS_BCA_PLUGIN" script='return ("$PLUGIN_NAME$".findFirst("Blue Cat")>-1) ? "1" : "0"' />

However, if you use too many build-time scripts, you may slow down skin loading time a bit. Also keep in mind, that scripts inside VARIABLEs are executed twice (for technical reasons), and that can be important if you're manipulating with something like file contents.

Descendent elements

  • VARIABLE
    • LOCAL_VARIABLE

Comments

Please, authorize to view and post comments.

2020 - 2025 © Site by LetiMix · Donate  |  Plug'n Script and KUIML by Blue Cat Audio