The DO loop is the simplest and most heavily used of the programming features
做循环是编程的最简单、最频繁使用的功能
of RATS (and any other statistical programming language).It’s a very simple
老鼠(和其他统计编程语言).这是一个非常简单
way to automate many of your repetitive programming tasks.The usual structure
自动化你的许多重复的编程任务.通常的结构
of a DO loop is:
的循环:
where N1,N2 and INCREMENT are integer number or variables.If INCREMENT
N1、N2和增量是整数数字或变量.如果增加
is omitted,the default value of 1 is used.The “index” is a name that you assign
省略,默认值为1.“指数”是一个名字,你分配
to be the counter through the loop.Typically,this is a (very) short name,with I,
通过循环计数器.通常,这是一个(非常)短名称,与我,
J and K being the most common ones.I and J are,in fact,defined variables in
J和K最常见的.事实上,我和J变量定义
RATS precisely because they are such common loop indexes (which is why you
老鼠,因为他们是如此常见的循环索引(这就是为什么你
can’t use the I name for an “investment” series).There is,of course,nothing
不能用我的名字为“投资”系列).当然,什么都没有
preventing you for using something more descriptive like LAG or DRAW.
阻止你使用更具描述性的滞后或画画.
The DO loop is really a counter.The first time that the DO instruction is executed,
做循环实际上是一个计数器.第一次做执行指令,
the index variable takes on the value N1 and the block of program
索引变量的值N1和块程序
statements is executed.On reaching the end of the loop,the index is increased
执行语句.在达到循环的结束,指数增加
by INCREMENT (that is,index is now N1+INCREMENT).If the index is less than
通过增量(即指数现在N1 +增量).如果该指数小于
or equal to N2,the block of program statements is executed again.On reaching
或等于N2,再次执行的程序语句块.到达
the end of the loop,the value of the index is again increased by INCREMENT
结束循环,指数再次增加了增量的值
and again compared to N2.This process is repeated until the value of the index
相比N2.重复这个过程直到指数的值
exceeds N2.At that point,RATS exits the loop and subsequent instructions can
超过了N2.在这一点上,老鼠可以退出循环和随后的指令
be performed.
被执行.