找回密码
 加入
搜索
查看: 1639|回复: 1

[AU3基础] 求助循坏读取文件行对比的问题

[复制链接]
发表于 2011-5-15 13:33:06 | 显示全部楼层 |阅读模式
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Input1 = GUICtrlCreateInput("Input1", 192, 80, 249, 21)
$Label1 = GUICtrlCreateLabel("输入要验证的编号:", 80, 80, 103, 17)
$Button1 = GUICtrlCreateButton("跟INI文件对比存不存在相同的", 144, 144, 305, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button1
                        _az()
                                        
        EndSwitch
WEnd
Func _az()
$read=GUICtrlRead($Input1)
$fo=FileOpen("d:\name.txt")
While 1
$txtr=FileReadLine($fo)        
If @error = -1 Then ExitLoop
If $read=$txtr Then 
        MsgBox(0,"","存在")
        ExitLoop
Else
        _bz()
EndIf
WEnd
EndFunc        

Func _bz()
MsgBox(0,"","我被跳了")        
        
EndFunc
现在的代码是,读取到第一行如果不相等,就跳到_bz()这个部份了(按正常来说。应该是读取所有行对比后,不相等,才跳转到 _bz()),我要实现的效果是:读取输入框的内容,然后跟name.txt文件对比,所有行都对比完成后,如果不存在,则转转至_bz(),如存在就提示存在:

name.txt的内容
532622198510020558
532926197706150714
533001197904150920
533001198208076039
533001198605280930
533001198703076618
533001198709150911
533001198801141217
533001198803267550
533001198805297219
533001199006150952
53300119910113511X
533001199103280046
533001199112065719
533001199202087217
发表于 2011-5-15 14:31:17 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Input1 = GUICtrlCreateInput("Input1", 192, 80, 249, 21)
$Label1 = GUICtrlCreateLabel("输入要验证的编号:", 80, 80, 103, 17)
$Button1 = GUICtrlCreateButton("跟INI文件对比存不存在相同的", 144, 144, 305, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button1
                        _az()
                                        
        EndSwitch
WEnd
Func _az()
If StringInStr(FileRead('temp.txt'), GUICtrlRead($Input1)) Then 
        MsgBox(0,0,'ok')
Else
        MsgBox(0,0,'no')
EndIf
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 08:16 , Processed in 0.070480 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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