Pre-processing - @set (Pre-processor)

Set the contents of a pre-processor variable.


JScript - 3.0
Internet Explorer - 4.0
JavaScript syntax:IE@set aVariable=aValue
Argument list:aValueA value to assign
aVariableA pre-processor variable name

You can define variables that exist in the namespace of the pre-processor and which can then be used as if they were directives that you had created. For example, you might test some complex set of conditions and set a variable so that you can simply test for its existence later. Or you might use that variable in some fragment of code as a manifest constant, perhaps to specify the size of an array or a flag to activate some capability.

You should note that these pre-processor directives will likely not survive from one script block to another or for any duration in the time domain. They are not variables in the sense of a script variable.

To create a new pre-processor variable, use the @set directive, name the variable and assign a value to it, like this:

@set @myvariable=1000

You can then use the variable in the source text like this:


You may need to experiment to establish how long one of these variables actually persists. It is unlikely to still be defined when an event handler is called. However, that event handler may have been interpreted and stored when the script was loaded, in which case the variable would have been replaced by its value at that time.

If you intend to hide this directive inside some comments, it must be done like this:

/*@set @myvariable=1000 @*/

See also:Pre-processing, Pre-processing - /*@ ... @*/