Limagito Filemover Software Blog and News

March 20, 2018

Pascal Script, generate a file

> Customer question: “I want to generate a file which is called “complete” in target folder after all files are moved to target folder”.

In this case you’ll need to add 2 Pascal Scripts.
First one ‘One Rule Begin’ script:

Begin
  psExitCode:= 1;
  // … add your code here
  psResetCounter;
End.
Second one ‘On Rule End’ Script (you need to adjust the ctFilePath value in the script):

Var
  tmpFile: TStringList;
Const
  ctFilePath = ‘C:\Test\Out\OutPS\’;
  ctFileName = ‘complete.txt’;
  ctFileContent = ‘dummy file’;
Begin
  psExitCode:= 1;
  // … add your code here
  If psCounter > 0 Then
  Begin
    tmpFile := TStringList.Create;
    Try
      Try
        tmpFile.Add(ctFileContent);
        tmpFile.SaveToFile(ctFilePath + ctFileName);
        psLogWrite(1, ”, ‘Save complete file succes’);
      Except
        psLogWrite(1, ”, ‘Save complete file error’);
      End;
    Finally
      tmpFile.Free
    End;
  End;
End.
By Limagito Limagito Filemover News Share: