Good day only my 3rd time in 25 years to use this kind of help.
I am using c5.5 h and do the following without knowing to be a problem.
I have 2 string variable -fromfile and tofile these variable gets filled with a drive file path and filename.
I use command Rename to copy fromfile to tofile.
Because of the directory called break it breaks loop 2 into loop 1 without renaming. It is not a word standing alone it is inside a string.
Comme4nt is there more such reserve word not to use so i can exclude them to be used by users???
Here is source code:
fromfile = f:\source\fromfile.pdf
tofile = c:\data\break\tofile.pdf - variable2
loop1
conditions to break loop 1
loop 2
other conditions to chek file string is correct and if not it breaks
rename(fromfile,tofile)
end
end
Firstly thanks for all the help, especially the error issue. I always used error(0 to do fault finding, but for some reason I drifted away from it.
The error WAS access denied. I eventually found it was the filename containing illegal characters.
Thanks for all the help.
I use below Err4Msg() function to easily get all the error functions info in a Message(). Also for a log file or debug passing (1).
MAP
Err4Msg PROCEDURE(Byte NoCRLF=0),STRING !Fromat ErrorCode() & Error() & FileError... for Message() Stop() Halt() or Log file (NoCRLF)
END
!-----------------------------------------
Err4Msg PROCEDURE(Byte NoCRLF=0)!,STRING
!Example: IF ERRORCODE() THEN STOP('Failed ADD(xxx)' & Err4Msg()).
!Note: Return starts '<13,10><13,10>Error Code:' so no need to put in the Message()
CODE
IF ~ERRORCODE() THEN RETURN ''.
IF ~NoCRLF THEN
RETURN '<13,10><13,10>Error Code: ' & ERRORCODE()&' '&ERROR() & |
CHOOSE(~FILEERRORCODE(),'','<13,10>Driver Error: ' & FILEERRORCODE()&' '&FILEERROR() ) & |
CHOOSE(~ERRORFILE(),'','<13,10>File Name: ' & ERRORFILE() )
END
!NoCRLF<>0 is 1 line format for use by logging
RETURN ERRORCODE()&' '&ERROR() & | ! {148}
CHOOSE(~FILEERRORCODE(),'',' [Driver ' & FILEERRORCODE()&' '&FILEERROR() &']' ) & |
CHOOSE(~ERRORFILE(),'',' {{' & ERRORFILE() & '}' )
So with your code:
rename(fromfile,ToFile)
IF ErrorCode() THEN
Message('Rename failed. Please investigate and report if problem persists.' & |
'||From File: ' & clip(Fromfile) & |
'|To File: ' & clip(Tofile) & |
Err4Msg() ,,ICON:Question,....
This would show a message like below where the last like is the output of Err4Msg():
=================================================================
Rename failed.
Please investigate and report if problem persists.
From File: f:\source\Prnstatementblank.pdf
To File: c:\data\break\Prnstatementblank.pdf
Error Code: 5 Access Denied
=================================================================