- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm developing a workaround for a colleague that needs to perform a lot of copy statements. "Call System("copy..")" does not work in this case. Therefore I tried to call the win32 API CopyFile using the kernel32 module. It gives the following errormessage:
Error: The same named entity from different modules and/or program units cannot be referenced. [COPYFILE]
The win32 API MoveFile workes fine though. I use compiler 10.1.029.
Here's the samplecode:
Cheers, Arjen
I'm developing a workaround for a colleague that needs to perform a lot of copy statements. "Call System("copy..")" does not work in this case. Therefore I tried to call the win32 API CopyFile using the kernel32 module. It gives the following errormessage:
Error: The same named entity from different modules and/or program units cannot be referenced. [COPYFILE]
The win32 API MoveFile workes fine though. I use compiler 10.1.029.
Here's the samplecode:
[fortran]Program CopyFile Use Kernel32 Implicit None Integer(BOOL) :: retval,NotOverWrite Character(Len=200) :: lpExistingFileName,lpNewFileName NotOverwrite = 0 lpExistingFileName = "D:\TestFile.txt" lpNewFileName = "D:\TestFile_copy.txt" retval = CopyFile(Trim(lpExistingFileName)//""C,Trim(lpNewFileName)//""C,FALSE) retval = MoveFile(lpExistingFileName,lpNewFileName) End Program CopyFile [/fortran]Thanks in advance for any useful answers!
Cheers, Arjen
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Your program is named CopyFile so it interfers with the function name.
Change "program CopyFile" to "program Copy_File" and it will work.
Your program is named CopyFile so it interfers with the function name.
Change "program CopyFile" to "program Copy_File" and it will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Auch, that indeed solves the problem. I thought Fortran was more tolerant in the name of the Program itself. Sorry to have bothered you with this, but thanks for the help anyway!
Cheers Arjen
Cheers Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In a Fortran program, no two entities in the "global" class may have the same name. These are: program units (main program, subroutines, functions, block data subprograms, modules), common blocks and external procedures.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page