zgyin的个人博客分享 http://blog.sciencenet.cn/u/zgyin

博文

class- for 循环

已有 3692 次阅读 2015-7-28 17:44 |个人分类:class|系统分类:科研笔记


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




https://blog.sciencenet.cn/blog-783377-908933.html

上一篇:class中定义的变量如何释放掉
下一篇:class-命令推迟执行
收藏 IP: 159.226.171.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

全部作者的精选博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-3-19 18:49

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部