找回密码
 加入
搜索
查看: 1848|回复: 3

[AU3基础] filereadline

[复制链接]
发表于 2014-12-22 02:35:11 | 显示全部楼层 |阅读模式
$file = FileOpen("test.txt", 0)

; 检查打开的文件是否可读
If $file = -1 Then
    MsgBox(0, "错误", "不能打开文件.")
    Exit
EndIf

; 每次读取一行文本,直到文件结束.
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "读取的行:", $line)
Wend

FileClose($file)

我想判断text.txt文本里面有等于778899的行,就执行a.exe  该怎么写呢
发表于 2014-12-22 08:05:32 | 显示全部楼层
本帖最后由 netegg 于 2014-12-22 08:20 编辑

$i =1
While not ($i>_filecountlines($file))
    $line = FileReadLine($file, $i)
    If @error = -1 Then ExitLoop
    if $line='778899' then run('a.exe')
    $i += 1
    ;MsgBox(0, "读取的行:", $line)
Wend
发表于 2014-12-22 08:18:08 | 显示全部楼层
本帖最后由 netegg 于 2014-12-22 08:21 编辑

$line = FileRead($file)
if stringinstr($line, '778899') then run('a.exe')
这样应该也行
发表于 2014-12-22 11:50:12 | 显示全部楼层
#Include <File.au3>
$CountLines = _FileCountLines($file)
If $CountLines >= 778899 Then MsgBox(0, 0, $CountLines)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-28 13:59 , Processed in 0.085019 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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