Writing a ASCII-File

Kromozone
Member Posts: 47
Hi Board,
I want to write an ASCII-File with some Parameters, separated by ";".
Is there a way to write this File by the piece and not as one big string?
If I write my Parameters with "file.write", Navision everytime writes an CRLF after it, but I want it as one long text without any Linefeeds
How can I prevent this?
Thank you
Rainy greetings from South-Germany!
Andy
I want to write an ASCII-File with some Parameters, separated by ";".
Is there a way to write this File by the piece and not as one big string?
If I write my Parameters with "file.write", Navision everytime writes an CRLF after it, but I want it as one long text without any Linefeeds

How can I prevent this?
Thank you
Rainy greetings from South-Germany!
Andy
0
Comments
-
Kromozone wrote:Hi Board,
I want to write an ASCII-File with some Parameters, separated by ";".
Is there a way to write this File by the piece and not as one big string?
If I write my Parameters with "file.write", Navision everytime writes an CRLF after it, but I want it as one long text without any Linefeeds
How can I prevent this?
Thank you
Rainy greetings from South-Germany!
Andy
I haven't really tested this. But there are a few ways to do it I should think. If you set textmode to false you will not get the CRLF appended. Another way would be to seek - -2 on the file everytime you have made a file.write.Best regards
Tommy0 -
Tommy Schou wrote:If you set textmode to false you will not get the CRLF appended.
But if Textmode is false, Navision writes an binary file, not an ASCII I thought.Tommy Schou wrote:Another way would be to seek - -2 on the file everytime you have made a file.write.
Can you explain how to? :oops:0 -
TestFile.CREATE('c:\tmp\test2.txt'); TestFile.OPEN('c:\tmp\test2.txt'); TestFile.TEXTMODE(TRUE); TestFile.WRITE('This is a test'); TestFile.SEEK(TestFile.POS-2); // Go back 2 positions in the file thus overwriting CRLF TestFile.WRITE('Line 2. CRLF should not exist'); TestFile.CLOSE;
The above should create a file with 2 lines in it.. where there is no CRLF between the lines.
There is however a CRLF at the very end... I tried getting rid of it by writingTestFile.SEEK(TestFile.POS-2); // Go back 2 positions in the file thus overwriting CRLF TestFile.TRUNC
before TestFile.Close. But though it should work. It apparently doesn't. Maybe you will have better luck!Best regards
Tommy0 -
Thank you
Will test it afterward...
Andy0 -
This problem is often solved by writing the file one Char at a time...
(CrLf is defined as Text with a length of 2...)... TestFile.TEXTMODE(FALSE); TestFile.CREATE('c:\tmp\TestFile.txt'); CrLf[1] := 13; CrLf[2] := 10; WriteString(Param1 + ';'); // first parameter... WriteString(Param2 + ';'); // second parameter... WriteString(Param3 + CrLf); // last parameter, add linefeed... TestFile.CLOSE; ... PROCEDURE WriteString(NewString : Text[250]) VAR i : Integer; BEGIN FOR i := 1 TO STRLEN(NewString) TestFile.WRITE(NewString[i]); END;
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