PB入门教程A
循环结构使得能够重复执行一行或多行代码,PowerBASIC支持以下几种循环结构
1. 原型:
FOR Counter = start TO stop [STEP increment] . {statements}
NEXT [Counter [, [Counter]] ...]
示例:
FOR n# = 1.0 TO 1.5 STEP 0.1 x$ = STR$(n#) NEXT n# 2. 原型:
WHILE integer_expression {statements} [EXIT LOOP] {statements} WEND 示例:
i& = 0
WHILE ISFALSE EOF(1) INCR i&
LINE INPUT #1, FileTxt$(i&) WEND
3. 原型:
DO [{WHILE | UNTIL} expression] {statements} …
[EXIT LOOP] [ITERATE LOOP] ...
LOOP {{WHILE | UNTIL} expression}
示例:
Count1 = 0
DO WHILE Count1 < 10 FOR Count2 = 0 TO 1 x = arry(Count1,Count2) Count1 = Count1 + 1 NEXT Count2 LOOP
DO…LOOP WHILE…WEND FOR…NEXT