(三) 语句

1、if语句

     if 条件表达式 then

语句块

     else

语句块

     endif;

或者是

    if 条件表达式 then

语句块

   elseif 条件表达式

语句块

    ....

   endif; 

例如:

 

 2、if goto语句

if 条件表达式 goto 标号;

例如:

 

3、switch .. endswitch;

  switch (表达式)

case 常量1: 语句1

  case 常量2: 语句2

…… 

default: 语句n+1 

  endswitch;

例如:

4、 while语句

 while (表达式)

语句块

endwhile;

注:不能在循环中定义标号 

例如: 

 

 

5、 repeat .. until语句

repeat

语句块

until (表达式); 

注:不能在循环中定义标号

例如:


6、 for .. endfor语句

 for X = A to B step C

语句块

endfor;

注:X为循环变量,A为初值,B为变量终值,C为单位步长。这里的to也可以变量成downto,如果省略step,则增量自动为1

注:不能在循环中定义标号

 

例如:

 

posted @ 2014-02-18 16:21  Fly Hawk  阅读(436)  评论(0编辑  收藏  举报