WriteString(): Add flag to set the line ending char

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

WriteString(): Add flag to set the line ending char

Post by Sicro »

For example:

Code: Select all

WriteString(File, Text$, #PB_File_CR)
WriteString(File, Text$, #PB_File_CRLF)
WriteString(File, Text$, #PB_File_LF)
WriteString(File, Text$, #PB_File_SystemEOL) ; The same as WriteStringN()
WriteString(File, Text$)
With this change, the command WriteStringN() will be not needed anymore.




----------------------------------------------------------------
My old post text:

For example:

Code: Select all

WriteStringN(File, Text$, #PB_File_CR)
WriteStringN(File, Text$, #PB_File_CRLF)
WriteStringN(File, Text$, #PB_File_LF)
Currently, WriteStringN() uses #CRLF$ as the ending line character under Windows and #LF$ under Linux.
Last edited by Sicro on Wed Jan 31, 2018 7:00 pm, edited 1 time in total.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: WriteStringN(): Add flag to set the line ending char

Post by Dude »

You can do it already:

Code: Select all

WriteString(File, Text$ + #CR$)
WriteString(File, Text$ + #CRLF$)
WriteString(File, Text$ + #LF$)
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: WriteStringN(): Add flag to set the line ending char

Post by Sicro »

Hello Dude

I'm aware of that.
However, the PB help tells you to use the "WriteStringN()" command when a line ending character is needed.
PB help: WriteString() wrote:Remarks
To write a string including a newline sequence, use the WriteStringN() function.
PB help: WriteStringN() wrote:Remarks
To write a string without a newline sequence, use the WriteString() function.
In fact, the "WriteStringN()" command could also be removed and allow the "WriteString()" command to support the following flags:
  • #PB_File_CRLF
  • #PB_File_LF
  • #PB_File_CR
  • #PB_File_SystemEOL
Last edited by Sicro on Wed Jan 31, 2018 7:02 pm, edited 1 time in total.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: WriteStringN(): Add flag to set the line ending char

Post by Demivec »

Sicro wrote:In fact, the "WriteStringN()" command could also be removed and allow the "WriteString()" command to support the following flags:
  • #PB_File_CRLF
  • #PB_File_LF
  • #PB_File_CR
  • #PB_File_SystemEOL (Default)
You actually would have to add a constant like #PB_File_NoLineEnding (Default) instead of the default you specified..
User avatar
Sicro
Enthusiast
Enthusiast
Posts: 538
Joined: Wed Jun 25, 2014 5:25 pm
Location: Germany
Contact:

Re: WriteStringN(): Add flag to set the line ending char

Post by Sicro »

Hello Demivec

Yes, sorry, the default value should be zero (none of the four constants mentioned above).
I have corrected my first and previous post accordingly.
Image
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Post Reply