Programmer Guide/Command Reference/SET: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==SET==
var := SET anyvalue


<code>var := [SET] anyvalue</code>
Assign a value to a variable. For example:


-> var = anyvalue
#question := set 'How much wood would a wood chuck chuck?'


Assign a value to a variable. If the keyword <code>SET</code> is not specified, the first word of anyvalue may not be any command! You can find out what keywords there are programatically using the <code>[[Programmer Guide/Command Reference/STXCONSTANTS|STXCONSTANTS]]</code> command.
Under certain conditions it is possible to omit the <code>SET</code> keyword altogether, but this is strongly discouraged (you can never be sure if these conditions apply).
 
For the curious: The keyword <code>SET</code> may be omitted if (and only if) the first word of the value to assign is ''neither'' a built-in {{STX}} command ''nor'' the name of a macro, member function, and so on. Since this is nearly impossible to guarantee, we strongly encourage to ''never omit the <code>SET</code> keyword.''

Revision as of 13:27, 15 April 2014

var := SET anyvalue

Assign a value to a variable. For example:

#question := set 'How much wood would a wood chuck chuck?'

Under certain conditions it is possible to omit the SET keyword altogether, but this is strongly discouraged (you can never be sure if these conditions apply).

For the curious: The keyword SET may be omitted if (and only if) the first word of the value to assign is neither a built-in STx command nor the name of a macro, member function, and so on. Since this is nearly impossible to guarantee, we strongly encourage to never omit the SET keyword.

Navigation menu

Personal tools