New Line in a Text File

Hanen
Member Posts: 281
Hello,
How can I write a new line in a textfile knowing that I'm using a dataport to create textfile. I tried this code but id didn't work
How can I write a new line in a textfile knowing that I'm using a dataport to create textfile. I tried this code but id didn't work

Dataport - OnPostDataport() CurrFile.TEXTMODE(TRUE);
Regards
Hanen TALBI
Hanen TALBI
0
Comments
-
Try this:
Dataport - OnPostDataport() CurrFile.TEXTMODE(FALSE); txtCRLF := 'XX'; // define it as Text with size 2 txtCRLF[1] := 13; txtCRLF[2] := 10; CurrFile.WRITE(txtCRLF);
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
It works but it's a new line with an additional blank #-o I only need a new line (cursor at first position without blanks)... :-k
THANKS FOR HELPRegards
Hanen TALBI0 -
My fault, it should have been the COPYSTR and not the text with size 2 (it may be of any length).
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));
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
-
Hi Hanen
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 helpsBig D signing off!0 -
Before trying Big D's trick, you can try this:
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!0 -
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 variable0 -
kriki wrote:Try this:
Dataport - OnPostDataport() CurrFile.TEXTMODE(FALSE); txtCRLF := 'XX'; // define it as Text with size 2 txtCRLF[1] := 13; txtCRLF[2] := 10; CurrFile.WRITE(txtCRLF);
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 isDataport - OnPostDataport() CurrFile.TEXTMODE(TRUE); CurrFile.WRITE('');
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?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions