write first line THEN write next until end

TrintTrint Member Posts: 44
edited 2003-08-11 in Navision Attain
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

Comments

  • WaldoWaldo Member Posts: 3,412
    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!

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • nav_devpnav_devp Member Posts: 47
    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;
Sign In or Register to comment.