GUI Manual · Chapter 32

Constant Value Editor

The Constant Value Editor defines the global constants used in scripts. Give frequently used fixed values a name and use the name instead of the number in scripts. The tab title shows Constant Editor.

Ways to open it:

  • Solution Explorer → Data Editor Pages → Constant Value Editor
  • Project → Global Constant Editor menu, or the Constant Value Editor button on the toolbar
  • In the script editor, place the caret on a constant name and press F12 (go to definition)

The path of the edited file (RunScript\ConstantValue.XDF) is shown at the top.

Constant Value Editor
Constant Value Editor

Table and buttons

ItemDescription
DefineConstant name. Case is ignored, and duplicates are not saved.
ValueConstant value
DescriptionDescription
Zoom in · Zoom out · 1:1Table text size
SAVESaves to the file and reloads the constants.
RESTOREReturns to the file contents after confirmation.
  • Click or drag the row numbers to select whole rows.
  • While editing, * is added to the tab title.

Caution Changes made with the Delete key, Ctrl+X or Increment Number do not add the * to the tab title, and closing the tab with only such changes discards them without asking. Press SAVE right after such edits.

Context menu

MenuAction
Add RowInserts an empty row below the selected row.
Insert Copied CellsShown only when the clipboard has several lines and the first column (Define) is selected. Inserts the copied lines as new rows below the selected row.
Duplicate RowCopies the selected row right below it.
Move Up · Move DownMoves the selected row by one.
Delete RowDeletes the selected rows (several rows allowed).
Increment NumberWith several cells selected in one column, fills the cells below with the top cell's number increased by 1 each. Enabled when the top cell is an integer; disabled when the selection starts at the first row.

Shortcuts

ShortcutFunction
DeleteClear the selected cells
Ctrl+DeleteDelete row
Ctrl+C / Ctrl+V / Ctrl+XCopy / paste / cut cells
Ctrl+DDuplicate row
Ctrl+Z / Ctrl+Shift+ZUndo / redo
Ctrl+0 / wheelTable text 100% / zoom in and out
Ctrl+SSave all and build (also saves this screen)

Using constants in scripts

Constants registered here are used by name in scripts. They are replaced by their values at build time, so they cost nothing at run time.

xscript
// If DEFAULT_SLEEP = 100 is registered in the Constant Value Editor
Sleep(DEFAULT_SLEEP);
  • If a variable has the same name as a constant, the variable is read in that scope and the build shows a warning. Rename the variable to use the constant.
  • If a name matches a built-in constant (EB_Ok, ER_Yes, etc.), the value registered here takes precedence.

Constants pay off for values used in several places or likely to change all at once later (wait times, repeat counts, vision tool numbers, etc.). See XScript — Language Basics for the detailed rules.

Subscribe