Jump to content

Pretty basic return value question


Recommended Posts

Hey all,

I use filecopy() in a script, but I want to log the success/failure of the command.

I know in the documentation it says the following:

Return Value

Success: Returns 1.

Failure: Returns 0.

But how do I access those return values?

My function call is like this:

FileCopy ( $CompletePath & "mission" & $NextMis & ".mis", $CompletePath & "currentmis.mis",1 )

Regards,

D

Link to comment
Share on other sites

Hey all,

I use filecopy() in a script, but I want to log the success/failure of the command.

I know in the documentation it says the following:

Return Value

Success: Returns 1.

Failure: Returns 0.

But how do I access those return values?

My function call is like this:

FileCopy ( $CompletePath & "mission" & $NextMis & ".mis", $CompletePath & "currentmis.mis",1 )

Regards,

D

Catch them in a variable

$variable = FileCopy ( $CompletePath & "mission" & $NextMis & ".mis", $CompletePath & "currentmis.mis",1 )
If $variable = 1 then
;Do something
Else
;Do something else
Endif
Edited by Paulie
Link to comment
Share on other sites

dodger42,

I think you want to look at how to use @error.

Do a search in the help file.

If @error = 1 Then MsgBox(0, "Successful", "Yes")
If @error = 0 Then MsgBox(0, "Successful", "No")

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

u can catch the returns of ALL the functions, even the ones u make yourself (aslong as there is an "return" in it).

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

dodger42,

I think you want to look at how to use @error.

Do a search in the help file.

If @error = 1 Then MsgBox(0, "Successful", "Yes")
If @error = 0 Then MsgBox(0, "Successful", "No")

taurus905

I don't think 'Filecopy' sets @error

but I could be wrong

@Dodger-

this executes it too

Link to comment
Share on other sites

I don't think 'Filecopy' sets @error

but I could be wrong

Paulie,

You are right. That's what I get for posting without testing first.

Global $Copied
_Copy_File()
If $Copied Then MsgBox(0, "Successful", "Yes")
If $Copied = 0 Then MsgBox(0, "Successful", "No")
Exit

Func _Copy_File()
    $Copied = FileCopy($CompletePath & "mission" & $NextMis & ".mis", $CompletePath & "currentmis.mis",1 )
    Return $Copied
EndFunc

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

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...