||
LAS> help for
[SIC]FOR Loop_Variable n1 n2 n3 TO n4 BY n5 n6 TO n7
or
[SIC]FOR /WHILE Logical_Expression
Open a FOR-NEXT loop to be executed for values in the list (FOR Vari-
able), or until a logical expression becomes false (FOR /WHILE). The
last character of the prompt becomes a ':' instead of '>', and all sub-
sequent commands typed in until NEXT are the body of the loop. Up to
nine loops may be nested in any way. The index of the loop will be sub-
stituted to the loop variable Loop_Variable during loop execution. The
substitution occurs also within character strings if the loop variable
name is included between single quotes. Note that the index values may
be real.
[SIC]FOR Loop_Variable n1 n2 n3 TO n4 BY n5 n6 TO n7
The loop specified in this example will execute for the following values
of the index :
n1
n2
n3, n3 + n5, n3 + 2 n5, n3 + 3 n5, ... , n4
n6, n6 + 1, n6 + 2, ... , n7
(assuming that n4-n3 is a multiple of n5, n7-n6 an integer). Loop vari-
ables are undefined outside the loop, and must not be previously de-
fined. Invalid ranges are ignored at execution time: e.g. in the previ-
ous example, the loop would not be executed for n3 TO n4 BY n5 if
n5*(n4-n3) < 0, but no error is signaled. Increments of 0 produce an er-
ror.
Conditional loops execute until the logical expression becomes false.
For example FOR /WHILE .TRUE. will execute forever.
上面是for循环的帮助信息,用for循环可以方便的写批处理程序。下面是一个简单的例子
LAS> for i 1 to 30 by 2 ! 循环变量是i 初始值是1,结束值是30,循环变量的变化步长是2,也就是循环变量每次加2
LAS: get 100+(i-1)*8 ! 获取 100+(i-1)*8对应的谱线
LAS: write
LAS: next i
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-27 09:46
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社