找回密码
 加入
搜索
查看: 1852|回复: 2

[系统综合] 怎么把这两段读取ini文件到变量的代码写的简单一些?

[复制链接]
发表于 2015-4-15 10:52:09 | 显示全部楼层 |阅读模式
原代码
$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);使用代理1  132
        ElseIf $Proxy_ON = 2 Then
                HttpSetProxy(2, $1Address & ':' & $1Port, $1Name, $1pass);使用代理2  130
        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段代码变得简单一些呢?
发表于 2015-4-17 16:58:41 | 显示全部楼层
名称部分用递增行不
发表于 2015-4-19 00:19:57 | 显示全部楼层
本帖最后由 netegg 于 2015-4-19 00:26 编辑

local $aItem[4] = ['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'))

剩下的自己琢磨吧
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-1 14:09 , Processed in 0.078518 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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