Pascal Script

  • 28 Sep

    How to wrap any lines longer than say 80 characters

    How to wrap any lines longer than say 80 characters

    Q: Is there a way when moving a text file to wrap any lines longer than say 80 characters?

    A: Yes this possible using the following Pascal Script as Destination

    • Add our Pascal Script option in your Destination setup
      • Don’t forget to adjust the  ctOutputPath  Const value.

    limagito file mover wrap any lines longer than

    Var
      iList: Integer;
      tmpEntry, tmpStrip: String;
      tmpFileIn, tmpFileOut: String;
      tmpListIn, tmpListOut: TStringList;  
    Const
      // Should be different than the Source path, must end with a \
      ctWordWrap = 80;
      ctOutputPath = 'C:\Test\Out_TXT\'; 
    Begin
      psExitCode := 0;
      tmpFileIn := psFilePath + psFileName;
      tmpFileOut := ctOutputPath + psFileName;
      // ... add your code here
      tmpListIn := TStringList.Create;
      tmpListOut := TStringList.Create;
      Try
        Try
          tmpListIn.LoadFromFile(tmpFileIn);
          // Iterate
          For iList := 0 to (tmpListIn.Count-1) Do
          Begin
            tmpEntry := tmpListIn.Strings[iList];
            if Length(tmpEntry) > ctWordWrap Then
            Begin
              Repeat
                tmpStrip := Copy(tmpEntry, 1, ctWordWrap);   
                tmpListOut.Add(tmpStrip);
                tmpEntry := Copy(tmpEntry, ctWordWrap+1, length(tmpEntry)-ctWordWrap);
                If Length(tmpEntry) <= ctWordWrap Then
                  tmpListOut.Add(tmpEntry);   
              Until Length(tmpEntry) <= ctWordWrap;  
            End
            Else
              tmpListOut.Add(tmpEntry); 
          End;
        Except
          psLogWrite(1, '', 'Error handling ' + tmpFileIn); 
        End;
        // Save Result
        Try
          psLogWrite(1, '', 'Saving ' + tmpFileOut);
          tmpListOut.SaveToFile(tmpFileOut);
          // Set Result to Successful
          psExitCode := 1;
        Except
          psLogWrite(1, '', 'Error saving ' + tmpFileOut); 
        End;    
      Finally
        tmpListIn.Free;
        tmpListOut.Free;
      End;    
    End.

     

    If you need any help about this ‘wrap any lines longer than’ request, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

  • 28 Aug

    How to convert UTF8-BOM to UTF8 by stripping the three-byte BOM

    Q: Can LimagitoX convert UTF8-BOM to UTF8 by stripping the three-byte BOM (EF BB BF) from files?

    A: Yes, please add a PScript as Destination:

    • Add the following script: link

    limagito file mover stripping the three-byte BOM

    Feedback customer:

    Thank you for your prompt response. Success! Thank you for your help.

    If you need any help about this ‘stripping the three-byte BOM’, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

  • 26 Aug

    How to add a no file edited trigger

    Q: How to add a no file edited trigger

    I have a question about how to carry out a specific task. I couldn’t find the answer on the blog, so I’m reaching out to you.
    Context :
    • I have 4 WIN sources, each containing 7 XML files.
    • These files can be edited or not every x minutes.
    Needs :
    • I need an email to be sent if the last write time of all the files exceeds 55 minutes.
      • In summary, if no files have been edited for over 55 minutes.

    A: Yes this is possible, please have a look at the following setup:

    • We used WIN as Source and added 4 local folders:

    limagito file mover WIN as source setup

    • Source Setup Result:

    limagito file mover source setup

    • Next, Moving Rule menu item > “Rule Events”

    limagito file mover rule events setup

    • Select and enable “On Rule Begin” > Pascal Script setup:
      • Check “Enable Pascal Script”
      • Add the Script: link

    limagito file mover on rule begin event

    • Select and enable “On Rule End” > Email Setup

    limagito file mover on rule end

    • Use a valid email address for both the “From” and “To” fields
    • Set Subject
    • Add information in the message Body (optional)

    limagito file mover on rule end email message setup

    • Keep “On Rule End” selected > Pascal Script Setup:
      • Check “Enable Pascal Script”
      • Add the Script: link

    limagito file mover add a no file edited trigger

    • Keep “On Rule End” selected > Options Setup:
      • Enable “Use Pascal Script as Event Precondition”

    limagito file mover on rule end options

    • File Filter Setup > Filename Include Filter: we are only looking for .xml files

    limagito file filter setup

    • File Filter Setup > File Date > Younger Than 55 minutes

    limagito file mover file date filter setup

    • Function Setup:
      • Set Function to Copy
        • We are not really going to “copy” files, we just want to leave the files at the WIN source(s)

    limagito file mover function setup

    • Destination Setup:
      • Add PScript as Destination, script: link
        • This script increase the Variable Integer A each time when a file younger than 55 minutes is found

    limagito file mover pascal script as destination

    • Enable and Execute Rule

    limagito file mover enable and execute rule

    • RunTime Log > Valid file(s) available

    limagito file mover runtime log

    • RunTime Log > No valid file avaible > Do Send Email

    limagito file mover runtime log

    If you need any help about this ‘add a no file edited trigger’, please let us know.

    Best Regards,

    Limagito Team

    #managedfiletransfer #filetransfer #filemanagement

1 2 3 4 5 32
SEARCH