How to save in text file

palanpalan Member Posts: 26
edited 2010-09-06 in Navision Attain
Hi,

I would like to know what is the returnversion in the below code & I want to save the returnversion in text file. How to do that? Can someone provide me some idea. Thanks.


IF STRPOS("No.",'R') <> 0 THEN
EVALUATE(ReturnVersion,DELCHR(COPYSTR("No.",STRPOS("No.",'R')+1,1)))
ELSE
ReturnVersion := 0;
IF ReturnVersion = 0 THEN
NewSalesOrderHeader."No." := "No." + 'R1'
ELSE
NewSalesOrderHeader."No." := COPYSTR("No.",1,STRPOS("No.",'R'))
+ 'R' + FORMAT(ReturnVersion + 2);

Comments

  • mabl4367mabl4367 Member Posts: 143
    I have not tested this but it should work.

    "FileName" is a variable with datatype Text, containing the name of the file you wish to create. As is evident from the code, the file will be erased if it already exists.

    The same file will be created every time and it will only contain the value of ReturnVersion in text format. You probably would want to construct the filename in some way that make it possible to figure out where the ReturnVersion value originated from. You could also write such information in the file itself.

    Anyway i think my code points you to some of the functions you can use to solve your problem.

    IF EXISTS(FileName) THEN
    ERASE(FileName);
    File.WRITEMODE(TRUE);
    File.TEXTMODE(TRUE);
    IF File.CREATE(FileName) THEN BEGIN
    File.WRITE(ReturnVersion);
    File.CLOSE();
    END;
  • palanpalan Member Posts: 26
    Hi,

    I have saved the returnversion to text file using the below code. Thanks for your help.


    file1.CREATE('c:\\test.txt');
    file1.CREATEOUTSTREAM(stream);

    stream.WRITETEXT(COPYSTR(temno,1,STRPOS(temno,'R')-1) + 'R' + FORMAT( ReturnVersion + 1));
    file1.CLOSE();
Sign In or Register to comment.