Jump to content

File check


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...