DataEase » Support » Knowledge Base » DataEase 7.2 Articles » How To Rename A File After It Is Printed

First of all create the following CDFs:

1) Function Name: IsFile
CDF library name: osfunc.dll
Return type: String

Create 2 parameters :
1-Name: Path/File Name Type: String
2-Name: Attributes to find Type: Int

2) Function Name: RenameFile
CDF library name: osfunc.dll
Return type: String

Create 3 parameters :
1-Name: Old File Name Type: String
2-Name: New File Name Type: String
3-Name: Notify User (Y or N) Type: String

Close and re-open your DataEase application (to register the CDF’s).

Copy and paste the following sample DQL code into a new procedure and amend where necessary (such as filenames). Compile and run:

define temp “tRet” number .
define temp “tOldFileNameAndPath” text 20 .
define temp “tNewFileNameAndPath” text 20 .

tOldFileNameAndPath := “C:\MyOldFile.pdf ” .
tNewFileNameAndPath := “C:\MyNewFile.pdf ” .

if IsFile (tOldFileNameAndPath, 00 ) = “True” then
tRet := RenameFile (tOldFileNameAndPath, tNewFileNameAndPath,”N”) .
else
message concat(“Please ensure file “, tOldFileNameAndPath, ” exists before proceeding”) window.
end