Applies To:
  • CitectSCADA 1.00, 1.01, 1.10, 1.11, 2.00, 2.01

Summary:
If you use the FileCopy() function in asynchronous mode (mode=4) and the copy fails, the return status value will be 0 - not an error code. This occurs as the copy is started by the FileCopy call, and continues asynchronous to your Cicode - the return value cannot contain the final error status. 

Solution:
If you must verify the copy status, don't use mode 4. If, however, you would still like the copy to be asynchronous to your Cicode, create a new Cicode task to call FileCopy in synchronous mode. For example:

INT
FUNCTION
MyFileCopy(STRING sSource, STRING sDest)
   INT status;

   status = FileCopy(sSource, sDest, 0);
   IF status <> 0 THEN
      Prompt("Copy failed");
   END
END
......
! create a new task to copy the file to give effect of async mode
TaskNew("MyFileCopy", "^"c:\citect\bin\readme.txt^",^"a:\readme.txt^"", 0);

Note that 99% of the time you should not have to do this, just use mode 0. If you use mode 0, it is synchronous to the Cicode task that called FileCopy, but it is asynchronous to all running Cicode tasks - it will not effect any other Cicode task or other Citect process. 


Keywords:
 

Attachments