<!--parser:xtscript-->
# random number
var $x = call mt_rand $min=1;$max=100
# The basic "if"
if $x > 50
print \$x is more than 50 <hr />
else
print \$x is less than 50<hr />
endif
# Strings can also be compared
var $a=abcdef
var $b=abcdeg
if $a < $b
print '$a' is less than '$b' <hr />
endif
# if's nested like this will not work
var $a=1
var $b=2
if $a == 3
if $b == 2
print \$b equals 2
endif
print \$a equals 3 ?<hr />
endif
# Most of the problems with nested "if's" can be overcome using "goto"
if $a == 3
print \$a equals 3
else
goto @end
endif
if $b == 2
print \$b equals 2
endif
@end
print no output because \$a does not equal 3 so \$b test is skipped
<!--/parser:xtscript-->
XtGem manual · all sections