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