Script

  • 24 Nov

    Pascal Script, User Request Example No 1

    Dear Users,

    We often get user specific questions. Not every request goes into our file transfer tool as an option. In such cases (and if it is possible) we create a custom Pascal Script for the end user.

    Example No1:

    People are asking a lot to LimagitoX. Today, a user asked me if I can make a LimagitoX rule with a filter on the number of lines in a file.

    Example:  Transfer the file if it contains more than 300 records.  The file type is *.txt

    The rule will be:

    Transfer files with less than 300 lines in weekday.

    Transfer files with more than 300 lines on Sunday.

    No transfer on Saturday.

    Do you think you can add such a kind of filter?

     

    For this request we created the ‘On Destination’ Pascal Script below. IMPORTANT: Be sure you set the file filter to only allow *.txt files

    image.png

    Var
      tmpList: TStringList;
      tmpNow: TDateTime;
    Begin
      psExitCode:= 0;
      // … add your code here
      tmpList := TStringList.Create;
      Try
        Try
          tmpList.LoadFromFile(psFilePath + psFileName);
          tmpNow := Now;
          // Transfer files with less than 300 lines in weekday ( 1 .. 5 ).
          If (tmpList.Count < 300) And (DayOfTheWeek(tmpNow) < 6) Then
          Begin
            psLogWrite(1, ”, ‘Line Count of ‘ + psFilePath + psFileName + ‘ = ‘ + IntToStr(tmpList.Count));
            psLogWrite(1, ”, ‘Day Of The Week is ‘ + IntToStr(DayOfTheWeek(tmpNow)));
            psExitCode := 1;
          End;
          // Transfer files with more than 300 lines on Sunday ( 7 ).
          If (tmpList.Count > 300) And (DayOfTheWeek(tmpNow) = 7) Then
          Begin
            psLogWrite(1, ”, ‘Line Count of ‘ + psFilePath + psFileName + ‘ = ‘ + IntToStr(tmpList.Count));
            psLogWrite(1, ”, ‘Day Of The Week is ‘ + IntToStr(DayOfTheWeek(tmpNow)));
            psExitCode := 1;
          End;
        Except
          psLogWrite(1, ”, ‘Exception error on loading ‘ + psFilePath + psFileName);
        End;
      Finally
        tmpList.free;
      End;
    End.
  • 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.
  • 27 Aug

    Considering Limagito as a replacement

    Hi, 

    We’re considering Limagito to replace our current solution. A few questions:
    1. We feed incoming filenames to a PERL script, which outputs the replacement filenames for the files at their destination. How could we accomplish this in Limagito?
    2. ..
    Thanx. Mark.
    Until now this wasn’t possible so we had to add this. To accomplish this we added some extra features to the Command option (v11.8.27.0).
    • Redirect Command Output to PS String Var A (%VSA)
    • Line Number to Redirecy to PS String Var A (%VSA).
    Both options are used to redirect the command output to the Ps string Var A (%VSA) which can be used later in the renaming of the destination filename. Setting the Line Number to 1 will take the first line of the command output. Setting it to 0 will take all available lines of the command output.
    Inline afbeelding 3
    The Perl script (or any other type of script) is triggered in the ‘Before Move/Copy/Delete’ command using the source filename (%SFN) as argument.
    Inline afbeelding 2
    Then we will use this string Var A in the file renaming option of your destination.
    Inline afbeelding 4
    The destination filename will be the output result of the script triggered in the Command option.
    Regards,
    Limagito Team
    By Limagito New Option , ,
1 2