Conditional Compilation Variables
On the previous page you saw some strange looking variables such as @_win32. These are predefined conditional compilation variables you can use to test for certain aspects of IE or the computer at large:
In most cases, you probably will be limited to just using @_win and @jscript_build:
/*@cc_on @if (@_win32) document.write("OS is 32-bit. Browser is IE."); @else document.write("OS is NOT 32-bit. Browser is IE."); @end @*/
User defined Variables
You can also define your own variables to use within the conditional compilation block, with the syntax being:
@set @varname = term
Numeric and Boolean variables are supported for conditional compilation, though strings are not. For example:
The standard set of operators are supported in conditional compilation logic:
You can test if a user defined variable has been defined by testing for NaN:
@if (@newVar != @newVar) //this variable isn't defined.
This works since NaN is the only value not equal to itself.