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
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.