MoodleScript: SET VARIABLE

MoodleScript Script Engine

Effect

Initialises a context key with a value or with the value of another variable.

Syntax

  SET VARIABLE <varname> FROM <litteral>
  SET VARIABLE <varname> FROM :<varname>
  SET VARIABLE <varname> FROM Litterals with :{<varname>} inside

Examples

  SET VARIABLE defautname FROM Default
  SET VARIABLE savedcourseid FROM :courseid
  SET VARIABLE extendeddefaultname FROM :{courseid}_with_extensions

Attributs particuliers

Notes

The created variable is installed in the global context of the execution stack for the lifetime of the script, until it is overridden by another assignment.

When a variable is created from another variable, the latter must be defined in the global context of the script, otherwise an empty value will initialise the new variable.

A combined literal form can call existing context variables. Sub-variable calls are replaced by those found in the context at execution time.

Other defaults

None

Back to the language index - Back to the component index