2Hi.Biz
Trang chủ | TWIG | Xtscript | Templates | Xtgem
xtscript Việt hóa 2015
AiChat.Wap.Sh
if
Nếu tuyên bố tạo ra các chi nhánh và các công tắc của Xtscript của bạn
[...] = optional ... = your valueif ... ...
[else
...]
endif
"Lồng nhau nếu nhân" có thể là một vấn đề trong xtscript
Hầu hết các vấn đề này có thể được khắc phục bằng cách sử dụng goto
Code ví dụ:
<!--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-->
Code đã chạy;
$x is more than 50
'abcdef' is less than 'abcdeg'
$a equals 3 ?
no output because $a does not equal 3 so $b test is skipped