Page 1 of 1

Issue with BOM

Posted: Thu May 23, 2024 11:57 am
by kinglestat
I had this code which worked on the 5.71 PB and now it doesn't with 6.1
has the BOM logic changed ?

Code: Select all

f = ReadFile( #PB_Any, filename, #PB_File_NoBuffering )

         If Not f
            filename = ""
            MessageRequester("LJLAng", "Could not read file")
         Else
            SetWindowTitle( #MainWindow, "Compiler - " + filename )
            
            format   = ReadStringFormat( f )             ;  Thanks to Infratec and Mesa
            LJLang::ValidTextFormat(format)
            
            body = ReadString(f,format | #PB_File_IgnoreEOL,#PB_File_IgnoreEOL)

Re: Issue with BOM

Posted: Thu May 23, 2024 12:25 pm
by Cyllceaux
This line is wrong

Code: Select all

body = ReadString(f,format | #PB_File_IgnoreEOL,#PB_File_IgnoreEOL)
The last Parameter is a number

Code: Select all

body = ReadString(f,format | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL, Lof(f))

Re: Issue with BOM

Posted: Thu May 23, 2024 6:03 pm
by infratec
In general you don't need this optional length parameter.
Only if you want to read an exact number of bytes.

Re: Issue with BOM

Posted: Thu May 23, 2024 8:19 pm
by HeX0R
Cyllceaux wrote: Thu May 23, 2024 12:25 pm

Code: Select all

body = ReadString(f,format | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL, Lof(f))
I prefer

Code: Select all

body = ReadString(f,format | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL, Lof(f))
:lol:

Re: Issue with BOM

Posted: Thu May 23, 2024 10:29 pm
by boddhi
HeX0R wrote:

Code: Select all

body = ReadString(f,format | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL, Lof(f))
:lol:
I hadn't dared!
But hey, let's be crazy, why not:

Code: Select all

body = ReadString(f,format | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL, Lof(f))
:mrgreen: :D :wink:

Re: Issue with BOM

Posted: Thu May 23, 2024 11:03 pm
by AZJIO

Code: Select all

Debug #PB_File_IgnoreEOL ; 65536
using the third parameter, the author of the topic limits the number of bytes read (65536). This may be the reason that a larger file will be truncated. The third parameter is not intended to use the constant #PB_File_IgnoreEOL , it looks absurd, an error.

Re: Issue with BOM

Posted: Fri May 24, 2024 4:30 am
by Cyllceaux
boddhi wrote: Thu May 23, 2024 10:29 pm
HeX0R wrote:

Code: Select all

body = ReadString(f,format | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL, Lof(f))
:lol:
I hadn't dared!
But hey, let's be crazy, why not:

Code: Select all

body = ReadString(f,format | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL | #PB_File_IgnoreEOL, Lof(f))
:mrgreen: :D :wink:
To be honest... I only saw the last Parameter and the constant... I didn't check it :oops:

Re: Issue with BOM

Posted: Fri May 24, 2024 5:40 am
by kinglestat
Thanks guys I will try it out

Re: Issue with BOM

Posted: Fri May 24, 2024 12:27 pm
by boddhi
Cyllceaux wrote: To be honest... I only saw the last Parameter and the constant... I didn't check it :oops:
It happens to everyone. Sometimes between precipitation and forgetting to modify elements in the message... We have the choice! :mrgreen:

It was just an opportunity to laugh a little... without thinking badly about it. :) :wink: