Pascal Script

  • 20 Mar

    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.
  • 26 Aug

    On Pascal Script Events

    Starting from version 11.8.26.0 we’ve added two new events:

    • On Pascal Script Success
    • On Pascal Script Error

    Events.PascalScript

     

    When enabled these events can be triggered by the psExitCode of any enabled Pascal Script.

    PascalScript.Events

     

    • Setting the psExitcode to 0 (zero) will trigger the ‘On Pascal Script Error’ event
    • Setting the psExitcode to 1 (one) will trigger the ‘On Pascal Script Success’ event
    • Setting psExitCode to any other value will not trigger the ‘On Pascal Script’ events

    Regards,

    Limagito Team

  • 18 Jul

    LimagitoX Pascal Script Example

    We get a lot of custom requests. We can’t add them all to LimagitoX File Mover so that is why the Pascal Script option was added.  To understand the possibilities of Pascal Script we will add some cases to our blog. Please feel free to ask us about the Pascal Script possibilities.

    Customer Request:

    Secondly, the destination for the moving rule is in two seperate locations. Essentially, files from 1-5000 need to go to one location and files over 5001 need to go to another. Is this a job for pascal script? If so do you know of any good tutorials on how to write it? The files are named 1Filename, 2Filename … all the way to 5000Filename

    Our solution was the following:

    Add two destinations:
    – files from 1-5000 need to go to one location => FIRST DESTINATION
    – and files over 5001 need to go to another. => SECOND DESTINATION
    Add the following ‘On Destinations’ Pascal Script:
    var
      i: integer;
      tmpInt: Integer;
      tmpStr: String;
    Begin
      psExitCode:= 0;
      // … add your code here
      tmpInt := -1;
      // Get Number Prefix
      for i := 4 downto 1 do
      begin
        tmpStr := LeftStr(psFilename, i);
        try
          tmpInt := StrToInt(tmpStr);
        Except
          //
        End;
        If tmpInt <> -1 Then
          Break;
      end;
      // Check Number Prefix
      If tmpInt <> -1 Then
      Begin
        If (tmpInt <= 5000) And (psDestinationID = ‘ID1’) Then
          psExitCode := 1;
        If (tmpInt > 5000) And (psDestinationID = ‘ID2’) Then
          psExitCode := 1;
      End
      Else
        psLogWrite(2, ‘[Prefix Number Check]’, ‘Not a valid prefix, ‘ + psFilename);
    End.

     

    By Limagito Pascal Script
1 5 6 7 8