Skip to main content

Calling builtins

  • Arguments are positional and every one is required. No builtin takes optional, named or variable-length arguments. The parameter names in the reference are labels only.
  • The argument count is checked when the script compiles, so a wrong count stops the script before anything runs.
  • Argument kinds are checked when the call runs, and they must match exactly, with one widening. An Integer where a Real is declared becomes that Real (MathSqrt(16) works), as it does in arithmetic. A Real where an Integer is declared, or a number where Text is declared (UtilityPrint(42)), stops the action with Name: argument N has the wrong type. Parameters shown as Any accept any kind.
  • Every builtin returns a value. Most actions return a Bool meaning "did it work", which you can ignore or test.
  • Missing things are normal results, not errors. A window that isn't found is a null Window. Passing a null Window, or a window that has closed, to a Window* builtin does nothing and returns false, 0 or "", so a chain of window calls on a handle that wasn't found is safe. Context builtins outside their trigger return "", 0, -1 or a null Window.
  • Plural results use enumerate-then-index. A call like WindowGetAllTopLevel(), FolderEnumerateAll(…), StringSplit(…) or DisplayMonitorEnumeratedAll() returns a count, and the matching …EnumeratedAt(i)/…PartAt(i) reads item i, from 0 to count − 1. Each family has one cache per script run, and the next enumerate call in that family replaces it.
  • A plugin can contribute builtins of its own. Their calls look the same. If the plugin isn't connected when the script compiles, the script doesn't run and a notification says why.
n = WindowGetAllTopLevel(); // count, and fills the window cache
for (i = 0; i < n; i = i + 1) {
w = WindowGetEnumeratedAt(i); // item i of that cache
if (WindowGetVisible(w) && WindowGetTitle(w)) {
UtilityPrint(WindowGetExecutableName(w) + " - " + WindowGetTitle(w));
}
}