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

[系统综合] 怎么从INI指定子段中,随机读取一个值,赋值给一个变量

  [复制链接]
发表于 2012-4-23 16:05:02 | 显示全部楼层 |阅读模式
比如,ini文件中内容如下

[ID]
1  =   aaa
2 =    bbb
3 =   ccc
4 =
5 =
.

在AU3脚本中,变量为$id
我要从INI文件中的ID下,随机取取1,2,3,4......其中的一个值给$id


代码应该怎么写
发表于 2012-4-23 16:08:59 | 显示全部楼层
[au3]local $section = inireadsection($ini, 'id')
msgbox(0,0,$section[random(1, $section[0][0], 1)][1])[/au3]
发表于 2012-4-23 16:09:22 | 显示全部楼层
回复 1# xtnetbar

稍稍动点脑子应该就出来了:
$s = IniReadSection('Your IniFile', 'ID')
If @error Then Exit
$r = Random(1, $s[0][0], 1)
$id = $s[$r][1]
发表于 2012-4-23 16:16:40 | 显示全部楼层
本帖最后由 sanmoking 于 2012-4-23 16:20 编辑

$var = IniReadSection("data.ini", "ID")
$id =$var[Random(1,$var[0][0],1)][1]
发表于 2012-4-24 22:01:08 | 显示全部楼层
学习Random函数了。。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-28 05:37 , Processed in 0.077615 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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