FIM++ 控制语句
第 18 章
8 年前
1248下面所有例子里,你可以用完整的表达式代替伪代码。 位于{...} 里面的部分是可选的。
while循环
语法:
I did this while <条件表达式>:
<当条件为真,执行这里的第一组语句>
{ It didn't work, but I knew why:
<当异常发生,执行这里的第二组语句来处理异常。如果没有第二组语句,则向虚拟机抛出异常> }
{ In the end, I did this instead:
<不管上面两条语句执行情况如何,最后都执行这里的第三组语句> }
That's what I did.for循环
语法:
I did this <数字> times :
<第一组语句>
{ It didn't work, but I knew why:
<第二组语句,同while循环> }
{ In the end, I did this instead:
<第三组语句,同while循环> }
That's what I did.你可以用I did this once或者I did this来代替I did this 1 times。
for循环和while循环很像,但指定了循环的次数。
if语句
When <条件表达式> :
<如果条件为真,执行这里的第一组语句>
{ In the end, I did this instead:
<如果条件为假,执行这里的第二组语句> }
That's what I did.注意:即使它看起来和上面两个很像,但这个结构体不会抛出异常。