Write Text File Does Not Work in RTC, Works Fine in Classic

matttraxmatttrax Member Posts: 2,309
edited 2011-02-01 in NAV Three Tier
Strangest thing. I am creating a text file using files and streams in a Codeunit. When I create this file from the Classic Client it comes out great. When I create the same file, in the same folder, on the same server, it writes blank lines equal to number of lines it should have written, and then a partial piece of the last line, everything but the first two characters.

The output to the file is from a BigText variable and is done via BigText.WRITE(Buffer). I checked this post, viewtopic.php?f=32&t=34321&hilit=bigtext, and I am doing everything the same way. I have also confirmed via message prompts directly before the writes that the BigText variable contains what I want to write to the file, but it should since it works fine in Classic.

I thought that maybe I would need to write it directly to a drive on the service tier for some reason, but that didn't work either.

Has anyone experienced this before? I am at a complete loss at this point. ](*,)

Comments

  • matttraxmatttrax Member Posts: 2,309
    Here's the actual test code.
    MyBigText.ADDTEXT('MyBigText');
    NewLine1 := 13;
    NewLine2 := 10;
    Filename := 'C:\Users\mtraxin\Documents\MattTest.txt';
    
    IF NOT MyFile.CREATE(Filename) THEN
      MyFile.OPEN(Filename);
    
    MyFile.CREATEOUTSTREAM(MyStream);
    
    FOR i := 1 TO 10 DO BEGIN
      MyBigText.WRITE(MyStream);
      MyStream.WRITE(NewLine1);
      MyStream.WRITE(NewLine2);
    END;
    
    MyFile.CLOSE;
    

    In Classic it produces this:
    "MyBigText
    MyBigText
    MyBigText
    MyBigText
    MyBigText
    MyBigText
    MyBigText
    MyBigText
    MyBigText
    MyBigText
    "

    In the RTC it produces this:
    "









    BigText"


    If it is a text variable it works fine in both, but not with BigText. I am going to have to do a TextArray for the time being, but I would love to know what is going on here.
  • deV.chdeV.ch Member Posts: 543
    I've seen other issues where bigtext & streams messes up the text... but that was related to the charset.

    I think there's somthing messed up with the bigtext var in the 3-tier.
  • deV.chdeV.ch Member Posts: 543
    ok now i got it, your problem is the position in the stream. Everytime you write directly in the stream the cr/lf you overwrite your data... try without the CR/LF part and you get your Text 'MyBigText' repeated 10 times.

    Add this:
    MyBigText.ADDTEXT(FORMAT(NewLine1)+FORMAT(NewLine2));
    

    instead of writing it in the stream
Sign In or Register to comment.