Q: I am looking for a way to incorporate date logic within our Limagito installation. I believe the easiest way to do this would be to use a Pascal Script, however I have not been able to find a syntax guide to assist me.
The date logic would be used in two places in a single rule that is run on a schedule. The first is in the file filter. Rule executes, I need to look for files that meet the pattern: NV_mmddyyyy.pdf where mmddyyyy is the date for the upcoming Friday.
- If it ran today (July 20, 2022), I would be looking for the filename that matched NV_07222022.pdf
The second place is in the path to the destination directory. The path looks like: c:\Jobs\mmdd_NV_WK\HotFolders\ where mmdd is the date for the upcoming Friday.
- If it ran today (July 20, 2022, the path would look like: c:\Jobs\0722_NV_WK\HotFolders\
Can you help us create a Pascal Script or provide us with a resource that has a syntax guide?
A: Could you please try the following:
Var
tmpDay: TDateTime;
Function GetNextFriday: TDateTime;
Var
iDay: Integer;
tmpDate: TDateTime;
Begin
Result := 0;
tmpDate := Now;
For iDay := 0 to 6 Do
begin
tmpDate := tmpDate + iDay;
// Check if Friday (= 5)
If DayOfTheWeek(tmpDate) = 5 Then
Begin
Result := tmpDate;
Break;
End;
End;
End;
Begin
psExitCode:= 1;
// ... add your code here
tmpDay := GetNextFriday;
If tmpDay <> 0 Then
Begin
psVSA := FormatDateTime('MMDDYYYY', tmpDay);
psVSB := FormatDateTime('MMDD', tmpDay);
End
Else
psExitCode:= 0;
End.
Next we need to adjust the File Filter Setup. The ‘Include Filename Filter’ will use the %VSA var (%VSA = Var String A) that was set in the previous Pascal Script.
Important, do not forget to enable ‘Allow parameters in File Name filter (File Filter > Advanced Tab)
Next, open Destination Setup and double click on your Destination:
RunTime Log Result:
#Filetransfer #Filemanagement
If you need any info about this ‘incorporate date logic’ question, please let us know.
Best regards,
Limagito Team