ScratchScript 1.0 Help

Imports

Every function defined in a .scrs file can be imported by another file (unless explicitly told not to export it). Importing a function also imports all of its dependencies.

To import functions, use the import keyword:

import * from "std/math"; // imports max() and min()

You can also include specific functions:

import { min } from "std/math"; // only imports min()

Or you can import all functions into a function namespace:

import * as math from "std/math"; // max() can only be accessed // via math.max() now

However, you cannot import specific functions into a function namespace:

import { min } as math from "std/math"; // invalid!

Standard

ScratchScript has a few standard scripts which include improvements to the language itself. All of them are contained in the std namespace, and any other file is not recommended to utilize it.

The standard currently includes these namespaces:

  • std/math (max() and min())

  • std/string (string extensions, like replace(), substring() and others)

  • std/string/unicode (unicode string handling, unicodeOf() and unicodeFrom())

There is also a std/global.scrs file which includes necessary functions for the compiler (like __Ternary(), __Exponent(), etc.), and is hence imported in every ScratchScript file by default and cannot be removed.

Last modified: 02 мая 2024