Javascript语言中的for语句格式
Javascript语言
语法:
for(initialize;test;increment){
statement
}
列:循环1到100的值
<script type="text/javascript">
var Value=0;
for (var a=0; a<=100; a++){
Value=Value+a;
}
document.write(Value);
</script>
Pascal语言中的for语句格式
Pascal语言
for 循环变量:=初始值 to 终止值 do 语句内容
或者
for 循环变量:=初始值 downto 终止值 do 语句内容
其他内容与C的相同,此处省略。
循环语句的含义在于从“控制变量”等于“初值”开始,循环到“终值”,当“控制变量”的值:
(1) to:大于终值时,终止循环。这里相当于BASIC中STEP(步长)=1的情况。
(2) downto:小于终值时,终止循环。 这里相当于BASIC中STEP(步长)=-1的情况。
BASIC语言中的for语句格式
BASIC语言
FOR 循环变量=初始值 TO 终止值 STEP 步长
语句内容
NEXT 循环变量
其他内容与C的相同,此处亦省略。C语言中的for语句格式
C语言
只要指定条件为 true 都执行语句块。
for (initialization; test; increment)
statements
参数
initialization
必选项。一个表达式。该表达式只在执行循环前被执行一次。
test
必选项。一个 Boolean 表达式。如果 test 是 true,则 statement 被执行。如果 test 是 false,则循环结束。
increment
必选项。一个表达式。在每次经过循环的最后执行该递增表达式。
statements
可选项。test 是 true 时,要执行的一个或多个语句。可以是复合语句。
说明
循环要执行确定的次数,通常使用 for 循环。
示例
下面的例子示范了一个 for 循环。
/* 在开始时 i 被设为 0,并在每次重复的最后被增加 1。
在循环重复前,
如果 i 不小于 10,则循环结束。*/
var myarray = new Array();
for (i = 0; i < 10; i++) {
myarray = i;
}
在c语言的解释是:
for:循环语句。
作用:循环。
它的一般形式为:
for(<初始化>;<条件表过式>;<增量>)
语句;
初始化总是一个赋值语句,它用来给循环控制变量赋初值;条件表达式是一个关系表达式,它决定什么时候退出循环;增量定义循环控制变量每循环一次后按什么方式变化。这三个部分之间用";"分开。
例如:
for(i=1;i<=10;i++)
语句;
上例中先给i赋初值1,判断i是否小于等于10,若是则执行语句,之后值增加1。再重新判断,直到条件为假,即i>10时,结束循环。
注意:
(1).for循环中语句可以为语句体,但要用"{"和"}"将参加循环的语句括起来。
(2).for循环中的"初始化"、"条件表达式"和"增量"都是选择项,即可以缺省,但";"不能缺省。省略了初始化,表示不对循环控制变量赋初值。省略了条件表达式,则不做其它处理时便成为死循环。省略了增量,则不对循环控制变量进行操作,这时可在语句体中加入修改循环控制变量的语句。
(3).for循环可以有多层嵌套。
例如:
for(;;) 语句;
for(i=1;;i+=2) 语句;
for(j=5;;) 语句;
这些for循环语句都是正确的。
FOR
field of regard 的缩写
[编辑本段]DOS命令中的FOR
对一组文件中的每一个文件执行某个特定命令。
FOR %variable IN (set) DO command [command-parameters]
%variable 指定一个单一字母可替换的参数。
(set) 指定一个或一组文件。可以使用通配符。
command 指定对每个文件执行的命令。
command-parameters
为特定命令指定参数或命令行开关。
在批处理文件中使用 FOR 命令时,指定变量请使用 %%variable
而不要用 %variable。变量名称是区分大小写的,所以 %i 不同于 %I.
如果命令扩展名被启用,下列额外的 FOR 命令格式会受到
支持:
FOR /D %variable IN (set) DO command [command-parameters]
如果集中包含通配符,则指定与目录名匹配,而不与文件
名匹配。
FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]
检查以 [drive:]path 为根的目录树,指向每个目录中的
FOR 语句。如果在 /R 后没有指定目录,则使用当前
目录。如果集仅为一个单点(.)字符,则枚举该目录树。
FOR /L %variable IN (start,step,end) DO command [command-parameters]
该集表示以增量形式从开始到结束的一个数字序列。
因此,(1,1,5) 将产生序列 1 2 3 4 5,(5,-1,1) 将产生
序列 (5 4 3 2 1)。
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
或者,如果有 usebackq 选项:
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
filenameset 为一个或多个文件名。继续到 filenameset 中的
下一个文件之前,每份文件都已被打开、读取并经过处理。
处理包括读取文件,将其分成一行行的文字,然后将每行
解析成零或更多的符号。然后用已找到的符号字符串变量值
调用 For 循环。以默认方式,/F 通过每个文件的每一行中分开
的第一个空白符号。跳过空白行。您可通过指定可选 "options"
参数替代默认解析操作。这个带引号的字符串包括一个或多个
指定不同解析选项的关键字。这些关键字为:
eol=c - 指一个行注释字符的结尾(就一个)
skip=n - 指在文件开始时忽略的行数。
delims=xxx - 指分隔符集。这个替换了空格和跳格键的
默认分隔符集。
tokens=x,y,m-n - 指每行的哪一个符号被传递到每个迭代
的 for 本身。这会导致额外变量名称的分配。m-n
格式为一个范围。通过 nth 符号指定 mth。如果
符号字符串中的最后一个字符星号,
那么额外的变量将在最后一个符号解析之后
分配并接受行的保留文本。
usebackq - 指定新语法已在下类情况中使用:
在作为命令执行一个后引号的字符串并且一个单
引号字符为文字字符串命令并允许在 filenameset
中使用双引号扩起文件名称。
某些范例可能有助:
FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k
会分析 myfile.txt 中的每一行,忽略以分号打头的那些行,将
每行中的第二个和第三个符号传递给 for 程序体;用逗号和/或
空格定界符号。请注意,这个 for 程序体的语句引用 %i 来
取得第二个符号,引用 %j 来取得第三个符号,引用 %k
来取得第三个符号后的所有剩余符号。对于带有空格的文件
名,您需要用双引号将文件名括起来。为了用这种方式来使
用双引号,您还需要使用 usebackq 选项,否则,双引号会
被理解成是用作定义某个要分析的字符串的。
%i 专门在 for 语句中得到说明,%j 和 %k 是通过
tokens= 选项专门得到说明的。您可以通过 tokens= 一行
指定最多 26 个符号,只要不试图说明一个高于字母 'z' 或
'Z' 的变量。请记住,FOR 变量是单一字母、分大小写和全局的;而且,
同时不能有 52 个以上都在使用中。
您还可以在相邻字符串上使用 FOR /F 分析逻辑;方法是,
用单引号将括号之间的 filenameset 括起来。这样,该字符
串会被当作一个文件中的一个单一输入行。
最后,您可以用 FOR /F 命令来分析命令的输出。方法是,将
括号之间的 filenameset 变成一个反括字符串。该字符串会
被当作命令行,传递到一个子 CMD.EXE,其输出会被抓进
内存,并被当作文件分析。因此,以下例子:
FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i
会枚举当前环境中的环境变量名称。
另外,FOR 变量参照的替换已被增强。您现在可以使用下列
选项语法:
~I - 删除任何引号("),扩充 %I
%~fI - 将 %I 扩充到一个完全合格的路径名
%~dI - 仅将 %I 扩充到一个驱动器号
%~pI - 仅将 %I 扩充到一个路径
%~nI - 仅将 %I 扩充到一个文件名
%~xI - 仅将 %I 扩充到一个文件扩展名
%~sI - 扩充的路径只含有短名
%~aI - 将 %I 扩充到文件的文件属性
%~tI - 将 %I 扩充到文件的日期/时间
%~zI - 将 %I 扩充到文件的大小
%~$PATH:I - 查找列在路径环境变量的目录,并将 %I 扩充
到找到的第一个完全合格的名称。如果环境变量名
未被定义,或者没有找到文件,此组合键会扩充到
空字符串
可以组合修饰符来得到多重结果:
%~dpI - 仅将 %I 扩充到一个驱动器号和路径
%~nxI - 仅将 %I 扩充到一个文件名和扩展名
%~fsI - 仅将 %I 扩充到一个带有短名的完整路径名
%~dp$PATH:i - 查找列在路径环境变量的目录,并将 %I 扩充
到找到的第一个驱动器号和路径。
%~ftzaI - 将 %I 扩充到类似输出线路的 DIR
在以上例子中,%I 和 PATH 可用其他有效数值代替。%~ 语法
用一个有效的 FOR 变量名终止。选取类似 %I 的大写变量名
比较易读,而且避免与不分大小写的组合键混淆。
[编辑本段]英语单词
prep. 1. (表示时间)在(某一特定时间); 在…时节; 持续达。2. (表示方向)向, 朝, 开往。3. (表示对象) 替, 帮, 给, 为…做准备, 对, 对于, 对…来说, 在…一方。4.(表示原因)因为, 由于, 作为…的结果。5. (表示距离)延续达, 计有。6.(表示结果)当做, 作为, 作为…的部分, 就…的条件而言。7. (表示目的)为了…, 适用于。8. (表示态度)支持, 赞同, 想要。 9. (表示比率)按…比例, 以…价格, 第…次
conj. 1. 因为, 由于
同义词
介词 prep.
代替
for,in,exchange,replacement,return,instead,of,place,a,as
以...为目的
as,with,of,in,to,become,the,looking,order,a,destination,destined,towards,for,goal,quest,so,seeking,purpose,view
喜欢
with,to,in,favorable,of,favor,supportsupportive
因为
to,adaptedappropriate,fit,suited,concerning,fitting
就...而论
of,the,in,contributive,to,honour,sake,interest
经过
throughout,through,during
至于
to,proportionate,regard,in,with,proportion,regards,as,respecting,reference
连接词 conj.
因为
seeing,because,that,whereas,as,since,forasmuch,inasmuch
反义词
介词 prep.
赞成;支持
against
。
开放分类:
编程语言,英语
[我来完善]
“for”相关词条:
更多
whileUNTILabstractreturnforeachautoswitch
“for”在英汉词典中的解释(来源:百度词典):
for
KK: []
DJ: []
prep.
1. 为,为了
2. 代替;代表
3. 因为,由于
4. 在(指定时间)
5. (表示时间、距离等)达,计
6. 对于,关于;在...方面
7. 为得到,为赢得
8. 以...为代价;以...交换
9. 当作,作为
10. 赞成;支持;倾向于
11. 朝...方向去;往,向
12. 就...而言
conj.
1. 因为,由于
参考资料:http://baike.baidu.com/view/124948.html?wtp=tt