Writing newline to a text file
Cem_Karaer
Member Posts: 281
How can I write newline to a text file by using the WRITE function of a FILE variable? Or is there any other way to do it?
Cem Karaer @ Pargesoft
Dynamics NAV Developer since 2005
Dynamics NAV Developer since 2005
0
Comments
-
A line ends with 10 and 13 characters.
Create a txt variable
MyEndLine[1] := 10;
MyEndLine[2] := 13;
in your code MyFile.write('your text'+MyEndLine);
If you set the MyFile.TEXTMODE(true);
Navision will add this so you don't have to.0 -
If MyEndLine is a text array, it is impossible to assign 10 or 13 values to this array.MyEndLine[1] := 10;
MyEndLine[2] := 13;Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050 -
cemkaraer wrote:
If MyEndLine is a text array, it is impossible to assign 10 or 13 values to this array.MyEndLine[1] := 10;
MyEndLine[2] := 13;
They need to be of the type "char" instead. And you probably need to do like this instead:
MyFile.write('your text'+MyEndLine[1] + MyEndLine[2]);
David
PS. By the way, the 10 and 13 are the ASCII numbers for carriage return and line feed. That's why they change line for you :-)0 -
The code above creates the following message:MyFile.write('your text'+MyEndLine[1] + MyEndLine[2]);
Microsoft Business Solutions-Navision
Type conversion is not possible because 1 of the operators contains an invalid type.
Text + Char
OK
Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050 -
MyFile.write('your text'+FORMAT(MyEndLine[1]) + FORMAT(MyEndLine[2]));0
-
wonmo wrote:MyFile.write('your text'+FORMAT(MyEndLine[1]) + FORMAT(MyEndLine[2]));
Thank you for the correction :-)
For cemkaraer: In general when you need to convert something to text, you can almost always use the FORMAT command. Works with chars, integers, decimals, dates and so forth.
-David0 -
cemkaraer wrote:
If MyEndLine is a text array, it is impossible to assign 10 or 13 values to this array.MyEndLine[1] := 10;
MyEndLine[2] := 13;
MyEndLine is not an array. It's text type. And text is an array of characters.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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
