Jump to content
Sign in to follow this  
TWC

exit on error

Recommended Posts

TWC

Forgive me for a stupid question but I have tried and can't make it work.

I want to run FileCopy("C:\test.txt","C:\testdir")

and if this fails I want the script to stop and exit.

THANX

Share this post


Link to post
Share on other sites
Valuater

maybe

$file = FileCopy("C:\test.txt","C:\testdir") 

if $file = 0 then exit

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
MrSpacely

Forgive me for a stupid question but I have tried and can't make it work.

I want to run FileCopy("C:\test.txt","C:\testdir")

and if this fails I want the script to stop and exit.

THANX

if you check the manual for the function filecopy note the Return Value section

Return Value

Success: Returns 1.

Failure: Returns 0.

so this would work

if FileCopy("C:\test.txt","C:\testdir") = 0 then exit

Share this post


Link to post
Share on other sites
MrSpacely

If Not FileCopy("C:\test.txt","C:\testdir") Then Exit

Lar.

arg same

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.