Why oh why Char 0?

SunsetSunset Member Posts: 201
Why does NAV5 suddenly put character 0 after each write to a file?

I have made myself a report to write data into a file with extreme length in every line. So I do as so often before.

fifile.create('path+name');
fifile.textmode(false);
fifile.writemode(true);

fifile.write(field1);
fifile.write(field2);
etc
etc

Has worked like a charm for years. So why oh why does navision now put Char(0) after each field?

Have tried various formatting of the fields I'm sending, writemode(false), Outstream.write. But every time a write is made, NAV insist on putting Char(0) into my line ](*,)
Don't just take my word for it, test it yourself

Comments

  • krikikriki Member, Moderator Posts: 9,110
    Try with:
    fifile.textmode(TRUE);
    


    If you REALLY need fifile.textmode(false);, you can also do this after each fifile.WRITE(...);
    f.SEEK(f.POS - 1);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • SunsetSunset Member Posts: 201
    I REALLY need it to be in textmode(false)

    f.SEEK(f.POS - 1) does the trick 8)

    But it leaves me with having various codelines depending on version :evil: (I wonder how it will work after SP X :-$ )


    "If it's not broken, don't fix it" apparently don't much any more :bug:
    Don't just take my word for it, test it yourself
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I don't think it's a bug. I think it's just the way it goes.

    With an outstream variable you will get the terminating null if you use
    OutS.WRITE
    
    If you use
    OutS.WRITETEXT
    
    you won't get it. So you can use OutStream to write into your file.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • kinekine Member Posts: 12,562
    Or you can use universal solution: write the string char by char:
    WriteString(var F:File; Text:Text 1000);
    begin
      for i:=1 to StrLen(Text) do
        F.WRITE(Text[i]);
    end;
    

    It will write it correctly...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.