I have had similar issues with created BACS files, a trick I used was to trim the file by two characters at the end - presuming that these final two characters are CR + LF...
Length := BACSFile.POS;
//Length of Type Integer
//BACSFile of Type File
BACSFile.CLOSE;
//Need to close and reopen the said file first.
BACSFile.OPEN(Filename);
// Filename used previously to open the file.
BACSFile.SEEK (gLength - 2);
BACSFile.TRUNC;
BACSFile.CLOSE;
Dataport - OnPostDataport()
CurrFile.TEXTMODE(FALSE);
txtCRLF := 'XX'; // define it as Text with size 2
txtCRLF[1] := 13;
txtCRLF[2] := 10;
CurrFile.WRITE(COPYSTR(txtCRLF,1,2));
CurrFile.SEEK(CurrFile.POS - 1); // if it doesn't work try with "- 2"
CurrFile.TRUNC; // try first without this command
Regards,Alain Krikilion No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
You Can Try to Create Integer DataItem In the Dataport with CONST(1) Then:
> Insert the DataportFields with variables
> In OnBeforeExport Trigger Insert Code for populate the variable
Dataport - OnPostDataport()
CurrFile.TEXTMODE(FALSE);
txtCRLF := 'XX'; // define it as Text with size 2
txtCRLF[1] := 13;
txtCRLF[2] := 10;
CurrFile.WRITE(txtCRLF);
kriki's first attempt was almost right. It accurately defines the newline string. His later addition of COPYSTR was not necessary (though not wrong; it produced the same result as the first attempt).
The problem with both these attempts is, though, that it is written in binary (non-text mode) in which a string is written with a trailing NUL character. The character on the last line in your screenshot is not a blank, but this NUL character (hex 00).
Big D's suggestion, on it's own, will not do you any good. kriki's latest suggestion, not regarding the comments, would probably correct the wrongly written byte, but why write it in the first place?
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
THANKS FOR HELP
Hanen TALBI
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Hanen TALBI
I have had similar issues with created BACS files, a trick I used was to trim the file by two characters at the end - presuming that these final two characters are CR + LF...
Length := BACSFile.POS;
//Length of Type Integer
//BACSFile of Type File
BACSFile.CLOSE;
//Need to close and reopen the said file first.
BACSFile.OPEN(Filename);
// Filename used previously to open the file.
BACSFile.SEEK (gLength - 2);
BACSFile.TRUNC;
BACSFile.CLOSE;
Hope this helps
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
> Insert the DataportFields with variables
> In OnBeforeExport Trigger Insert Code for populate the variable
The problem with both these attempts is, though, that it is written in binary (non-text mode) in which a string is written with a trailing NUL character. The character on the last line in your screenshot is not a blank, but this NUL character (hex 00).
So, what you should do is
Big D's suggestion, on it's own, will not do you any good. kriki's latest suggestion, not regarding the comments, would probably correct the wrongly written byte, but why write it in the first place?