f.READ

mickuk
Member Posts: 47
Hi All,
Probably a really simple question but does anyone know of any method that is built into Navision that deals with reading lines froma file in an easy way. I'm not a seasoned Navision programmer and I'm a little lost.
I'm looking for a method that will allow me to read separate lines from a file. I've tried f.READ however that appears only to return the entire contents of the file.
For example my test file consists of the following...
1,4556667,56
3,4787678,65
3,5564333,67
If I output the "line" that I've read in from this file I get the entire contents. I've looked at f.TEXTMODE which I presume should be set to true (based on my past experience of file output with Navision to avoid binary type files/no end of line).
This is my test code...
The output from this simply relays the entire contents of the file back through a message box; however what I am aiming for is for each line to be read separately. Any help would be appreciated.
Probably a really simple question but does anyone know of any method that is built into Navision that deals with reading lines froma file in an easy way. I'm not a seasoned Navision programmer and I'm a little lost.
I'm looking for a method that will allow me to read separate lines from a file. I've tried f.READ however that appears only to return the entire contents of the file.
For example my test file consists of the following...
1,4556667,56
3,4787678,65
3,5564333,67
If I output the "line" that I've read in from this file I get the entire contents. I've looked at f.TEXTMODE which I presume should be set to true (based on my past experience of file output with Navision to avoid binary type files/no end of line).
This is my test code...
IF EXISTS('filename.txt') THEN BEGIN importFile.OPEN('filename.txt'); WHILE importFile.POS < importFile.LEN DO BEGIN importFile.READ(in_line); MESSAGE(in_line); END; END ELSE MESSAGE('The import file does not exist');
The output from this simply relays the entire contents of the file back through a message box; however what I am aiming for is for each line to be read separately. Any help would be appreciated.
0
Comments
-
If TEXTMODE it set to TRUE, READ should return just one line instead of the whole text. If it is a unix generated text file, this will not work (only LF = LineFeed at the end of the line without a CR = CarriageReturn as used in Windows) without converting the file to the windows text file type.
http://kb.iu.edu/data/acux.htmlKai Kowalewski0 -
Thanks for the information. This is however quite strange as the file that I'm using has been produced on a windows based machine using notepad. One would assume that this should have the correct EOL characters.
Is there any other reason why this would fail? When I useLength := STRLEN(in_line);
I get the total number of characters in the file. I assume that this should report back the number of characters that is within the line that has been read (in_line). If this was the case then that would be a lot less than what is currently being returned.
Thanks in advance
EDIT
=============================
Solved....
I had been messing with the code when i had a free moment and realised that I has set textmode on my output file but not on my input #-o
=============================0 -
Try this:
IF EXISTS('filename.txt') THEN BEGIN importFile.WRITEMODE(FALSE); importFile.TEXTMODE(TRUE); importFile.OPEN('filename.txt'); WHILE importFile.READ(txtLine) > 0 DO BEGIN MESSAGE('%1',txtLine); END; importFile.CLOSE; END ELSE MESSAGE('The import file does not exist');
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks kriki that worked fine. Missed the most obvious thing on there.....the TEXTMODE :whistle: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