Core Function FileCopy

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> FileCopy( <file1>, <file2>, <flag> ) </pre> === Description === Copy a file. === Parameters === ==== file1 ==== The file to copy. ==== file2 ==== The new file name a...")
 
(Return Value)
 
(9 intermediate revisions by one user not shown)
Line 19: Line 19:
 
==== flag ====
 
==== flag ====
  
If the flag is higher than 0 the FileCopy will overwrite any existing file at the location.
+
If the flag is true FileCopy will overwrite any existing file at the location.
  
 
Default is not to overwrite.
 
Default is not to overwrite.
Line 25: Line 25:
 
=== Return Value ===
 
=== Return Value ===
  
Success: Returns 1.
+
Success: Returns true.
  
Failure: Returns 0 if error occurs.
+
Failure: Returns false if error occurs.
  
 
=== Remarks ===
 
=== Remarks ===
Line 38: Line 38:
 
FileCopy("Sputnik.exe", "Cats.exe"); // Copy but dont overwrite
 
FileCopy("Sputnik.exe", "Cats.exe"); // Copy but dont overwrite
 
FileCopy("Sputnik.exe", "Cats.exe", 1); // Copy but dont DO overwrite
 
FileCopy("Sputnik.exe", "Cats.exe", 1); // Copy but dont DO overwrite
 +
</syntaxhighlight>
 +
 +
Example using [[Macros#Error|@Error]] macro
 +
<syntaxhighlight lang="sputnik">
 +
FileCopy("catNotExist.exe", "Dog.exe");
 +
if(@Error)
 +
{
 +
say("There was an error");
 +
say("Error code: " . @ErrorCode);
 +
say("Error message: " . @ErrorMsg);
 +
}
 +
else
 +
{
 +
say("There was no error");
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 21:07, 17 June 2015

FileCopy( <file1>, <file2>, <flag> )

Contents

Description

Copy a file.

Parameters

file1

The file to copy.

file2

The new file name and location.

flag

If the flag is true FileCopy will overwrite any existing file at the location.

Default is not to overwrite.

Return Value

Success: Returns true.

Failure: Returns false if error occurs.

Remarks

None.

Example

FileCopy("Sputnik.exe", "Cats.exe"); // Copy but dont overwrite
FileCopy("Sputnik.exe", "Cats.exe", 1); // Copy but dont DO overwrite

Example using @Error macro

FileCopy("catNotExist.exe", "Dog.exe");
if(@Error)
{
	say("There was an error");
	say("Error code: " . @ErrorCode);
	say("Error message: " . @ErrorMsg);
}
else
{
	say("There was no error");
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox