怎么把这两段读取ini文件到变量的代码写的简单一些?
原代码$0Address = IniRead("config.ini", "Proxy", "0Address", "")
$0Port = IniRead("config.ini", "Proxy", "0Port", "")
$0Name = IniRead("config.ini", "Proxy", "0Name", "")
$0pass = IniRead("config.ini", "Proxy", "0pass", "")
$1Address = IniRead("config.ini", "Proxy", "1Address", "")
$1Port = IniRead("config.ini", "Proxy", "1Port", "")
$1Name = IniRead("config.ini", "Proxy", "1Name", "")
$1pass = IniRead("config.ini", "Proxy", "1pass", "")
$Proxy_ON = IniRead("config.ini", "Proxy", "Proxy_ON", "0")
.....................
Func _ProxyOn()
If $Proxy_ON = 1 Then
HttpSetProxy(2, $0Address & ':' & $0Port, $0Name, $0pass);使用代理1132
ElseIf $Proxy_ON = 2 Then
HttpSetProxy(2, $1Address & ':' & $1Port, $1Name, $1pass);使用代理2130
ElseIf $Proxy_ON = 3 Then
HttpSetProxy(2, IniRead("config.ini", "Proxy", "Proxy_3", ""));文献代理 一般 能用
Else
HttpSetProxy(1);不使用代理
EndIf
If $iconFreeFlag = True Then HttpSetProxy(1) ;proxytag
EndFunc ;==>_ProxyOn
-------------
HttpSetProxy(2, IniRead("config.ini", "Proxy", "Proxy_3", ""));文献代理 一般 能用
这个是错误的,不用看。
现在想把ini代理数增加,原来只用2个代理,现在可能会增加到8个代理。
如果一个一个增加,比较麻烦了,怎么写,能让上面2段代码变得简单一些呢? 名称部分用递增行不 本帖最后由 netegg 于 2015-4-19 00:26 编辑
local $aItem = ['Address', 'Port', 'Name', 'pass']
for $i = 0 to 1
for $j = 0 to 3
assign($i & $aItem[$j], IniRead("config.ini", "Proxy", "0" & $aItem[$j], "")
next
next
Func _ProxyOn($i)
HttpSetProxy(2, eval(($i-1) &' Address') & ':' & eval(($i-1) &'Port'),eval(($i-1) &'Name'), eval(($i-1) &'pass'))
剩下的自己琢磨吧
页:
[1]