Appie78 Posted March 18, 2009 Share Posted March 18, 2009 Hi guys, I'm trying to get the Msgbox to pop up! Somehow it doesn't. When I change the -1 to 1 and the file is there it gives the msgbox. Is this the correct way to do this? CODE $sString = FileRead("c:\program files\scan sample\Positions.log") If $sString = -1 Then MsgBox(0, "Error", "Unable to open logfile.") Exit EndIf Thanks, Pokerface Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
foster74 Posted March 18, 2009 Share Posted March 18, 2009 Success: Returns the binary/string read. Special: Sets @error to -1 if end-of-file is reached. Failure: Sets @error to 1 if file not opened in read mode or other error. Sets @error to 2 if count not defined for file open in raw read mode. So: $sString = FileRead("c:\program files\scan sample\Positions.log") If $error = -1 Then MsgBox(0, "Error", "Unable to open logfile.") Exit EndIf Link to comment Share on other sites More sharing options...
Appie78 Posted March 18, 2009 Author Share Posted March 18, 2009 Success: Returns the binary/string read. Special: Sets @error to -1 if end-of-file is reached. Failure: Sets @error to 1 if file not opened in read mode or other error. Sets @error to 2 if count not defined for file open in raw read mode. So: $sString = FileRead("c:\program files\scan sample\Positions.log") If $error = -1 Then MsgBox(0, "Error", "Unable to open logfile.") Exit EndIf Thanks Foster74, Didn't check the helpfile on the errors!! Ps. $error = @error Electron microscopes rule!!! Link to comment Share on other sites More sharing options...
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