InStream.READ wrong behavior

JAJJAJ Member Posts: 52
Hi everyone.

I need to process big files in "textmode" = FALSE. I have the code bellow :

InStr = InStream
size = Integer
BigTextFile = BigText
TempText =Text 1024
...

WHILE NOT InStr.EOS DO BEGIN
size := InStr.READ(TempText, 1024);
BigTextFile.ADDTEXT(TempText);
END;

BigTextFile.WRITE(OutStr);

...

With this code if the file is multiple of 1025, it only process 1024 bytes.

If I put the code bellow :

...

WHILE NOT InStr.EOS DO BEGIN
InStr.READ(TempText, 1024);
BigTextFile.ADDTEXT(TempText);
END;

BigTextFile.WRITE(OutStr);

...

I get the error bellow :

The stream cannot find a zero-terminated string.
The stream may be invalid....


Anybody knows what is the problem??

Thanks in advance!

Regards.

Comments

  • ara3nara3n Member Posts: 9,256
    I just tried it on nav 2009 r2 and it works correctly;
    myfile.OPEN('C:\Temp\TADA.TXT');
    myfile.CREATEINSTREAM(InStr);
    
    
    WHILE NOT InStr.EOS DO BEGIN
    SIZE := InStr.READ(TempText, 1024);
    //BigTextFile.ADDTEXT(TempText);
    MESSAGE(TempText);
    END;
    

    it returned the first 1024 characters then the last digit.

    my file was
    11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • JAJJAJ Member Posts: 52
    ara3n wrote:
    I just tried it on nav 2009 r2 and it works correctly;
    myfile.OPEN('C:\Temp\TADA.TXT');
    myfile.CREATEINSTREAM(InStr);
    
    
    WHILE NOT InStr.EOS DO BEGIN
    SIZE := InStr.READ(TempText, 1024);
    //BigTextFile.ADDTEXT(TempText);
    MESSAGE(TempText);
    END;
    

    it returned the first 1024 characters then the last digit.

    my file was
    11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    


    Hi ara3n,

    Thanks for your response, but in my NAV cliente runs wrong. Could you tell me which version of Dynamics NAV R2 do you have?

    Thanks in advance.
  • ara3nara3n Member Posts: 9,256
    I used finsql.exe 6.0.32012
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • JAJJAJ Member Posts: 52
    ara3n wrote:
    I used finsql.exe 6.0.32012

    Hi,

    I used 6.00.32900. But I think that your test it was not correcty. Your file is 1026 kb, and with this size runs ok, Could you test with a file with 1025 kb?

    Thanks.
  • ara3nara3n Member Posts: 9,256
    Yes, I just tested it with 1025 bytes and I can replicate it. It's a bug.

    I tested it on RTC and I did get two message boxes in classic I only get one message box.

    I suggest to report it to MS.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • JAJJAJ Member Posts: 52
    ara3n wrote:
    Yes, I just tested it with 1025 bytes and I can replicate it. It's a bug.

    I tested it on RTC and I did get two message boxes in classic I only get one message box.

    I suggest to report it to MS.


    Thanks a lot.
  • ara3nara3n Member Posts: 9,256
    No, thank you. :D
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.