write first line THEN write next until end

Trint
Member Posts: 44
i need this to write to the next line instead of overwriting the previous line until all that is left is the last line of this table in a text file:
Catalog.GET(CatalogCode);
CatalogFile.TEXTMODE := TRUE;
CatalogFile.WRITE( '"' + Catalog.Code +'"' + ',' +
'"' + Catalog.Name +'"' + ',' +
'"' + Catalog."Season Code" + '"');
currently the text in the file looks like this:
"3","3","3"
it needs to look like this:
"1","1","1"
"2","2","2"
"3","3","3"
thanks,
Trint
Catalog.GET(CatalogCode);
CatalogFile.TEXTMODE := TRUE;
CatalogFile.WRITE( '"' + Catalog.Code +'"' + ',' +
'"' + Catalog.Name +'"' + ',' +
'"' + Catalog."Season Code" + '"');
currently the text in the file looks like this:
"3","3","3"
it needs to look like this:
"1","1","1"
"2","2","2"
"3","3","3"
thanks,
Trint
0
Comments
-
I didn't get exactly what you were trying to do, so I created 2 scenario's:
//First scenario CLEAR(myFile); myFile.TEXTMODE(TRUE); myFile.WRITEMODE(TRUE); myFile.QUERYREPLACE(FALSE); myFile.CREATE('c:\test'); myFile.WRITE('1' + ',' + '1' + ',' + '1'); myFile.WRITE('2' + ',' + '2' + ',' + '2'); myFile.WRITE('3' + ',' + '3' + ',' + '3'); myFile.CLOSE; //Second scenario CLEAR(myFile); myFile.TEXTMODE(TRUE); myFile.WRITEMODE(TRUE); myFile.QUERYREPLACE(FALSE); myFile.CREATE('c:\test2'); myFile.WRITE('1' + ',' + '1' + ',' + '1'); myFile.CLOSE; CLEAR(myFile); myFile.TEXTMODE(TRUE); myFile.WRITEMODE(TRUE); myFile.QUERYREPLACE(FALSE); myFile.OPEN('c:\test2'); myFile.SEEK(myFile.LEN); myFile.WRITE('2' + ',' + '2' + ',' + '2'); myFile.CLOSE;
I didn't know if you created the file at once (=first scenario), or if you just had to add a new line to an allready existing file (=second scenario). I tested both, and approved. My guess is the 'SEEK' is what you were looking for ...
Enjoyed!0 -
Hi Trint,
Is this what u looking for
outFile.OPEN('c:\abc.txt');
outFile.CREATEOUTSTREAM(oStream);
IF Cust.FIND('-') THEN
REPEAT
oStream.WRITETEXT('"');
oStream.WRITETEXT(Cust."No.");
oStream.WRITETEXT('"');
oStream.WRITETEXT(',');
oStream.WRITETEXT('"');
oStream.WRITETEXT(Cust.Name);
oStream.WRITETEXT('"');
oStream.WRITETEXT;
UNTIL Cust.NEXT=0;
outFile.CLOSE;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