Dynamic File names
Dynamic file names is a quite common task and there are multiple ways of doing it
Calculations
It is possible to use calculated filenames by placing calculation inside {}
Note:
Only one pair of {} is allowed
For example:
This will use today date to generate the filename
C:\Data\{GetSystemDate('YYYYMMDD')}.txt
and that one will use yesterdays date
C:\Data\{DecDateS(GetSystemDate('YYYYMMDD'),'YYYYMMDD','DAY',1)}.txt
Variables
<CommonDocumentsDir>\DBSL\{GetSystemVariable('SOURCE_FILE_NAME')}.txt
Note:
<CommonDocumentsDir> is a variable and will be replaced with an actual value before execution
C:\Data\{GetVariable('<file_name>')}.txt
More complex example
This calculation will create a new file every time [F001] is changed
begin
if GetVariable('<file_name>')<>[F001] then record changed
begin
SetVariable('<file_name>',[F001]);
SourceChanged; creating new file
end;
Result:='test';
end;