Jump to content
Sign in to follow this  
Frank_O

Using returncode or @error

Recommended Posts

Frank_O

Hi all,

please don't blame me, but at the moment I'm totally dumb.

Normally I use "$ret = function( ..." and of course it's working fine. But totay I tried to use"@error" and this is not working as I expected ...

What am I doing wrong?

gives "ok":

$ret = FileCopy( "c:\Temp\ldif.log", "c:\temp\ldif.log2", 9 )

if $ret = 1 Then

msgbox( 64, "COPY", "Copy is done" )

Else

msgbox( 16, "COPY", "ERROR copying file" )

EndIf

gives "error":

FileCopy( "c:\Temp\ldif.log", "c:\temp\ldif.log2", 9 )

if @error Then

msgbox( 64, "COPY", "Copy is done" )

Else

msgbox( 16, "COPY", "ERROR copying file" )

EndIf

Please help a clueless one ...

Frank

Share this post


Link to post
Share on other sites
MHz

FileCopy() does not support the @error macro so it will never set @error (e.g. @error will always be 0).

:)

Edit:

FileCopy returns 0 or a non 0 result, like using True or False, so you can just do this.

If FileCopy("c:\Temp\ldif.log", "c:\temp\ldif.log2", 9) Then
    MsgBox(64, "COPY", "Copy is done")
Else
    MsgBox(16, "COPY", "ERROR copying file")
EndIf
Edited by MHz

Share this post


Link to post
Share on other sites
Frank_O

Hi MHz,

that's cool. And now I know, that not all functions support @error ...

Thank you.

Frank

Share this post


Link to post
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
Sign in to follow this  

×