Mellon Posted September 22, 2011 Posted September 22, 2011 This was supposed to be a quick and dirty program to complete a one off project. It hasn't been quick. I have a list of vessel names. These vessel have brought our software and we need to make sure that they are offered an upgrade to a regulatory module we sell. The program should. 1) Get the name of the vessel from a file on the local machine. 2) Loop through a file text file (purchased.txt) until to comes to the last entry, searching for the word Dealer. 3) Add the vessel and Dealer name to a third file 4) Close the vessel's text file. 5) Start over again at 1 from the next vessel This works splendidly for the first vessel on the list. However, it seems to get stuck in the Do loop. The information never gets written to file and first purchased.txt file never gets closed. Is "until @error=-1" valid? While 1 $VesselName=FileReadLine($Get_Vessel_Name) $VesselPath=$customerdatalocation & $VesselName &"\Purchased.txt" ;Loop until you reach the end of the File $Dothefile=Fileopen($Vesselpath,0) GUICtrlSetData ( $Label1 , $Vesselpath) Do $LookforLastDealer=FileReadLine($DotheFile) $whoisthedeal=StringInStr($LookforLastDealer,"Dealer") if $Whoisthedeal<> 0 Then $Thedealer=$LookforLastDealer ;$Whoisthedeal=0 $thestatus=@error msgbox(1,$Whoisthedeal, $Thestatus) EndIf until @error=-1 msgbox(1,"2", $Thedealer) $Whatthefuck=FileWrite($Vesselwithdealer,$VesselName&" "& $Thedealer) fileclose($Dothefile) WEnd
Beege Posted September 22, 2011 Posted September 22, 2011 @error is a value used by all autoit functions. Anytime you call any autoit function, @error is reset to 0. If your are looking to see if filereadline() has set @error to -1, it must be checked directly after the call. $LookforLastDealer=FileReadLine($DotheFile) if @error = -1 then exitloop Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator
AdmiralAlkex Posted September 22, 2011 Posted September 22, 2011 Or save @error to a variable if you want to check it later .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Mellon Posted September 22, 2011 Author Posted September 22, 2011 Thanks. By happenstance I have always used @error=-1 right after a file read so I never ran into this before.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now