找回密码
 加入
搜索
查看: 2510|回复: 5

这样子写不行,请问一下要怎么写?

[复制链接]
发表于 2009-6-14 20:05:30 | 显示全部楼层 |阅读模式
Local $HostNameA
$HostName = StringSplit(IniRead($inipath, "A区", "机器列表", ""), ",")
for $i = 0 to $HostNameA[0]
If @ComputerName=$HostNameA[$i] Then
run($runa)
EndIf


Local $HostNameB
$HostName = StringSplit(IniRead($inipath, "B区", "机器列表", ""), ",")
for $i = 0 to $HostNameB[0]
If @ComputerName=$HostNameB[$i] Then
run($runab)
EndIf



Local $HostNameC
$HostName = StringSplit(IniRead($inipath, "C区", "机器列表", ""), ",")
for $i = 0 to $HostNameC[0]
If @ComputerName=$HostNameC[$i] Then
run($runc)
EndIf



Local $HostNameD
$HostName = StringSplit(IniRead($inipath, "D区", "机器列表", ""), ",")
for $i = 0 to $HostNameD[0]
If @ComputerName=$HostNameD[$i] Then
run($rund)
EndIf
Exit




[A区]
机器列表=A001,A002,A003
程序=
[B区]
机器列表=B081,B082,B083
程序=
[C区]
机器列表=C131,C132,C133
程序=
[D区]
机器列表=D151,D152,D153
程序=
发表于 2009-6-14 20:18:27 | 显示全部楼层
本帖最后由 lynfr8 于 2009-6-14 20:20 编辑
for $i = 1 to $HostNameA[0]
If @ComputerName=$HostNameA[$i] Then
run($runa)
EndIf
next
$i = 0是返回数组总数,从1开始才是返回值
另外
for to next才是完整的循环语句
发表于 2009-6-14 22:45:44 | 显示全部楼层
...学习了。。。。
 楼主| 发表于 2009-6-15 14:39:13 | 显示全部楼层
$inipath = @ScriptDir& "\" &"update.ini"
$runa=IniRead($inipath, "A区", "程序", "")
$runb=IniRead($inipath, "B区", "程序", "")
$runc=IniRead($inipath, "C区", "程序", "")
$rund=IniRead($inipath, "D区", "程序", "")
Local $HostNameA
$HostName = StringSplit(IniRead($inipath, "A区", "机器列表", ""), ",")
for $i = 1 to $HostNameA[0]
If @ComputerName=$HostNameA[$i] Then
run($runa)
EndIf

Exit


Local $HostNameB
$HostName = StringSplit(IniRead($inipath, "B区", "机器列表", ""), ",")
for $i = 1 to $HostNameB[0]
If @ComputerName=$HostNameB[$i] Then
run($runb)
EndIf

Exit


Local $HostNameC
$HostName = StringSplit(IniRead($inipath, "C区", "机器列表", ""), ",")
for $i = 1 to $HostNameC[0]
If @ComputerName=$HostNameC[$i] Then
run($runc)
EndIf

Exit


Local $HostNameD
$HostName = StringSplit(IniRead($inipath, "D区", "机器列表", ""), ",")
for $i = 1 to $HostNameD[0]
If @ComputerName=$HostNameD[$i] Then
run($rund)
EndIf

Exit

这样写还是不行啊
发表于 2009-6-16 07:56:37 | 显示全部楼层
Local $HostNameA
$HostName = StringSplit(IniRead($inipath, "A区", "机器列表", ""), ",")
for $i = 1 to $HostNameA[0]
If @ComputerName=$HostNameA[$i] Then
run($runa)
EndIf

很明显,你声明的变量为$HostNameA,而你在使用 INIread 函数时,使用的变量为$HostName
而在使用 FOR ....next 循环时使用的是数组$HostNameA[0] ,毛病是不是出在这!?
发表于 2009-6-16 13:42:37 | 显示全部楼层
学习了,谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-26 09:17 , Processed in 0.091016 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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