===== MoodleScript: SET VARIABLE ===== ===== MoodleScript Script Engine ===== === Effect === Initialises a context key with a value or with the value of another variable. === Syntax === SET VARIABLE FROM SET VARIABLE FROM : SET VARIABLE FROM Litterals with :{} inside === Examples === SET VARIABLE defautname FROM Default SET VARIABLE savedcourseid FROM :courseid SET VARIABLE extendeddefaultname FROM :{courseid}_with_extensions ===Attributs particuliers=== * **varname**: The name of the variable to create, without spaces or special characters. * **litteral**: A literal string === 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 [[:local:moodlescript:languagespecification|Back to the language index]] - [[:local:moodlescript|Back to the component index]]