Posts: 9
Threads: 2
Joined: Jun 2024
When I write:
CHDR "D:\Test_with_Files"
A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B
A is existing on the harddrive but File B is not created. Why is that?
Posts: 62
Threads: 7
Joined: May 2024
(06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:
CHDR "D:\Test_with_Files"
A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B
A is existing on the harddrive but File B is not created. Why is that?
What does ERR say? This might give a clue.
„Let the machine do the dirty work.“
The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978
Posts: 9
Threads: 2
Joined: Jun 2024
06-15-2025, 06:21 PM
(This post was last modified: 06-15-2025, 06:26 PM by Tillmann Viefhaus.)
(06-15-2025, 06:00 PM)Albert Richheimer Wrote: (06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:
CHDR "D:\Test_with_Files"
A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B
A is existing on the harddrive but File B is not created. Why is that?
What does ERR say? This might give a clue.
There is no ERR message. And thats whats suspicious. The command just doesn't work. Or does it write the new file elsewhere on the drive?
(06-15-2025, 06:21 PM)Tillmann Viefhaus Wrote: (06-15-2025, 06:00 PM)Albert Richheimer Wrote: (06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:
CHDR "D:\Test_with_Files"
A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B
A is existing on the harddrive but File B is not created. Why is that?
What does ERR say? This might give a clue.
There is no ERR message. And thats whats suspicious. The command just doesn't work. Or does it write the new file elsewhere on the drive?
I found the error. I just had the wrong filename which was the one of the program I was working with. The file A used in FILECOPY must never contain the name or parts of the name of a programm which is just running.
Posts: 62
Threads: 7
Joined: May 2024
06-15-2025, 07:50 PM
(This post was last modified: 06-15-2025, 07:51 PM by Albert Richheimer.)
(06-15-2025, 06:21 PM)Tillmann Viefhaus Wrote: I found the error. I just had the wrong filename which was the one of the program I was working with. The file A used in FILECOPY must never contain the name or parts of the name of a programm which is just running.
No. The running program only has a write lock applied. I still can be read – what PB's filecopy is doing.
I just have tested it:
Code:
#compile exe
#dim all
function pbmain () as long
local sFileA as string
local sFileB as string
sFileA = "test.exe" ' This running program
sFileB = "copy_of_test.exe"
filecopy sFileA,sFileB
if err then
stderr str$(err)+": "+error$(err)
end if
if isfile(sFileB)=0 then
stderr "Filecopy did not succeed."
end if
end function
The filecopy is doing fine.
„Let the machine do the dirty work.“
The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978
Posts: 22
Threads: 4
Joined: May 2024
06-16-2025, 12:17 AM
(This post was last modified: 06-16-2025, 12:23 AM by Dale Yarker.)
'Question is in PowerBASIC for Windows section, so changed Albert's code
'to PBWin from PBCC.
'
'I was curious if FileA is itself the running EXE containing FILECOPY.
'But that works fine also. (see #COMPILE line)
'
Code:
#compile exe "test.exe"
#dim all
'
function pbmain () as long
local sFileA as string
local sFileB as string
sFileA = "test.exe" ' This running program
sFileB = "copy_of_test.exe"
filecopy sFileA,sFileB
if err then
'stderr str$(err)+": "+error$(err)
? str$(err)+": "+error$(err)
end if
if isfile(sFileB)=0 then
'stderr "Filecopy did not succeed."
? "Filecopy did not succeed."
end if
? "done"
end function '
'that leaves CHDR "D:\Test_with_Files"
'1. is the program that is doing the FILECOPY in D:\Test_with_Files ?
'2. if FileA is not in D:\Test_with_Files it will not be found by FILECOPY.
'
'code in post 1 had no error checking and PB does not display "messages"
'unless asked.
'
'Cheers,