找回密码
 加入
搜索
查看: 1585|回复: 4

请教For...In...Next?

[复制链接]
发表于 2008-12-6 15:21:07 | 显示全部楼层 |阅读模式
找来找去都找不到For...In...Next的中文使用方法,
哪位知道怎么用,请给个简单的说明,谢谢了

[ 本帖最后由 superflq 于 2008-12-7 16:37 编辑 ]
发表于 2008-12-6 15:27:40 | 显示全部楼层
算1+2+3+4+5
$s=0
for $i=1 to 5
    $s+=$i
    msgbox(0,0,"第"&$I&"次累加后S="&$s)
next
发表于 2008-12-6 15:57:09 | 显示全部楼层
For...In...Next 
--------------------------------------------------------------------------------

Enumerates elements in an Object collection or an array


For <$Variable> In <expression>
    statements
    ...
Next


 

Parameters

Variable A variable to which an element is being assigned 
expression Must be an expression resulting in an Object, or an Array with at least one element 

 

Remarks

The Variable will be created automatically with a LOCAL scope, even when MustDeclareVars is on.
If the expression is an Object collection with no elements, the loop will be skipped and the Variable will contain an empty string.
If the expression is not an Object nor an Array, the script stops with an error, unless a COM Error handler had been configured.

For...In...Next statements may be nested.


 

Related

With...EndWith, ObjEvent (COM Error handler) 
 

Example


;Using an Array
Dim $aArray[4]

$aArray[0]="a"
$aArray[1]=0
$aArray[2]=1.3434
$aArray[3]="test"

$string = ""
FOR $element IN $aArray
    $string = $string & $element & @CRLF
NEXT

Msgbox(0,"For..IN Arraytest","Result is: " & @CRLF & $string)

;Using an Object Collection

$oShell = ObjCreate("shell.application")
$oShellWindows=$oShell.windows

if Isobj($oShellWindows) then
  $string=""

  for $Window in $oShellWindows
    $String = $String & $Window.LocationName & @CRLF
  next

  msgbox(0,"","You have the following windows open:" & @CRLF & $String)
else

  msgbox(0,"","you have no open shell windows.")
endif
 楼主| 发表于 2008-12-6 17:19:00 | 显示全部楼层
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
    MsgBox(0, "Link Info", $oLink.href)
Next


$oLink.href 这里后面为什么有个.href
我要怎么读取$oLinks,输出到.ini或者.txt
要怎么写
发表于 2008-12-6 22:31:35 | 显示全部楼层
找下早期的AU3版本中的帮助大部分是中文的
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-17 20:04 , Processed in 0.073906 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表