Read and re-write a text file

Oneway
Member Posts: 53
all experters
Could you guys tell me how to make this happen in code not dataport?
I have a text file SoureceFile looks like below:
A fjkmknkmn dvkmlf dklmf
B 32987329873290320932
C 987390URHIRFKJFEKKKDCM0
D 89798KNECFNKCFKLMCLMF
........................
.................
and I want to create a new text file NewFile same structure as above
but without line D. Total stream is large than 1024
notice: the second line is a blank line
Could you guys tell me how to make this happen in code not dataport?
I have a text file SoureceFile looks like below:
A fjkmknkmn dvkmlf dklmf
B 32987329873290320932
C 987390URHIRFKJFEKKKDCM0
D 89798KNECFNKCFKLMCLMF
........................
.................
and I want to create a new text file NewFile same structure as above
but without line D. Total stream is large than 1024
notice: the second line is a blank line
0
Comments
-
"Total stream is large than 1024" : you mean that a line can be larger than 1024?Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Yes!
every text line is lager than 10240 -
Try this:
globals:
Name DataType Subtype Length
filRead File
filWrite File
cha Char
intLine IntegerfilRead.WRITEMODE(FALSE); filRead.TEXTMODE(FALSE); filRead.OPEN('c:\temp\x.txt'); filWrite.QUERYREPLACE(FALSE); filWrite.WRITEMODE(TRUE); filWrite.TEXTMODE(FALSE); filWrite.CREATE('c:\temp\xx.txt'); intLine := 1; WHILE filRead.READ(cha) > 0 DO BEGIN IF cha = 13 THEN BEGIN // 13-10 found : end-of-line reached intLine += 1; filRead.READ(cha); END; // this is the line I DON'T want IF intLine <> 5 THEN filWrite.WRITE(cha); END; filRead.CLOSE; filWrite.CLOSE;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks lots!!!
but it seems does not work correct.
thanks anyway.0 -
What is not working correctly?Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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