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

如何得到Func字段里的值

[复制链接]
发表于 2009-10-16 02:35:38 | 显示全部楼层 |阅读模式
Func kahao()
         $Val = Random ( 1, 10, 1 );1:行数的最小值,2:行数的最大值,1:设为1则返回整数
      $kahao = FileReadLine ( "data.ini" , $Val )
EndFunc
上边命令是读取data.ini里边的数据。 data.ini数据如下。
0078571023
0078558650
0078558581
0078550241
0078549468
0078551771
0078558565
0078557337
0078553524
0078551796

然后 我用下边代码来获取kahao()的值 为什么显示是0?

$shuru=kahao()
MsgBox(4096, "Test", $shuru , 10)

请高手赐教!
发表于 2009-10-16 02:57:24 | 显示全部楼层
data.ini
0078571023
0078558650
0078558581
0078550241
0078549468
0078551771
0078558565
0078557337
0078553524
0078551796
GetVal.au3
$vfile = "data.ini"
$nRandomLine = Random(1,nReadLine($vfile)-1,1);注:nReadLine($vfile)-1,取INI文件的总行数,如果在最后一行是回车符则减1,没有回车符则不需减1
MsgBox(0,"第"&$nRandomLine&"的内容是",FileReadLine($vfile,$nRandomLine))

Func nReadLine($Val)
   $file = FileOpen($Val, 0)
   $xTemVal=0
   While 1
      $line = FileReadLine($file)
      $xTemVal = $xTemVal + 1
      If @error = -1 Then ExitLoop
   Wend
   FileClose($Val)
   return $xTemVal
EndFunc
发表于 2009-10-16 03:06:24 | 显示全部楼层
楼主的:
Func kahao()
         $Val = Random ( 1, 10, 1 );1:行数的最小值,2:行数的最大值,1:设为1则返回整数
      $kahao = FileReadLine ( "data.ini" , $Val )
         return $kahao
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-22 04:02 , Processed in 0.074863 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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