WriteStringN() extra parameter
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
WriteStringN() extra parameter
We need an extra parameter to specify line ending type - CR, LF and CRLF
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: WriteStringN() extra parameter
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
Re: WriteStringN() extra parameter
Dude has already written in this topic why this wish is unnecessary.Sicro wrote:Related: WriteString(): Add flag to set the line ending char
It would make more sense to have a command that writes a string with a terminating 'Null' character.
E.g. WriteStringT for 'Write String Terminated'.
sorry for my bad english
Re: WriteStringN() extra parameter
It is not unnecessary to propose alternative solutions, just because there is already a solution. Perhaps there are better, clearer solutions than the built-in solution.Josh wrote:Dude has already written in this topic why this wish is unnecessary.
Such a command / flag would be good, too.Josh wrote:It would make more sense to have a command that writes a string with a terminating 'Null' character.
E.g. WriteStringT for 'Write String Terminated'.
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
Re: WriteStringN() extra parameter
I like optional flags and small features that make it simpler to achieve common tasks...
But I don't get this one, it just makes it longer to type common commands?
It can be easily macro'ed, like
But I don't get this one, it just makes it longer to type common commands?
Code: Select all
WriteString(File, Text$ + #CRLF$)
; or
WriteString(File, Text$, #PB_File_CRLF)
WriteStringN(File, Text$)
; or
WriteString(File, Text$, #PB_File_SystemEOL)
It can be easily macro'ed, like
Code: Select all
Macro WriteStringCRLF(File, Text, Format = #Null)
WriteString((File), Text + #CRLF$, (Format))
EndMacro
Macro WriteStringLF(File, Text, Format = #Null)
WriteString((File), Text + #LF$, (Format))
EndMacro
Re: WriteStringN() extra parameter
Originally, this thread is about an extra parameter for WriteStringN(). My linked thread is about WriteString().
In the beginning the wish of my thread was exactly the same as in this thread. The command description in the PB help for WriteString() tempts you to use the WriteStringN() command if you want a new line after the string:
But the removal of a programming language command that exists since a long time is very serious, because many existing codes do not work anymore due to such a change.
The best option is, I think, to leave the commands as they are, and only the description of the command WriteString() should be improved. There should be a hint that WriteString() can also be used when a new line should be appended after the string. Unlike the WriteStringN() function, newline formats other than the operating system standard are also possible.
Some people will think that such a hint is ridiculous, but sometimes such simple solutions do not come to mind. So it would be good if the command description pointed this out and didn't confuse with just a reference to WriteStringN().
In the beginning the wish of my thread was exactly the same as in this thread. The command description in the PB help for WriteString() tempts you to use the WriteStringN() command if you want a new line after the string:
After further considerations, I then revised my first post in my thread. My thought was: Why is another function WriteStringN() necessary, which differs only very slightly from the function WriteString(). Isn't it enough to just add another flag to WriteString()? Besides the existing constants there has to be another constant #PB_File_SystemEOL or #SystemEOL and the function WriteStringN() is no longer needed.PB help wrote:To write a string including a newline sequence, use the WriteStringN() function.
But the removal of a programming language command that exists since a long time is very serious, because many existing codes do not work anymore due to such a change.
The best option is, I think, to leave the commands as they are, and only the description of the command WriteString() should be improved. There should be a hint that WriteString() can also be used when a new line should be appended after the string. Unlike the WriteStringN() function, newline formats other than the operating system standard are also possible.
Some people will think that such a hint is ridiculous, but sometimes such simple solutions do not come to mind. So it would be good if the command description pointed this out and didn't confuse with just a reference to WriteStringN().
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
Re: WriteStringN() extra parameter
It's just a quick one-minute search/replace with any given tool to fix that for all sources in a folder. Not a serious problem at all.Sicro wrote:But the removal of a programming language command that exists since a long time is very serious, because many existing codes do not work anymore due to such a change.
And PureBasic has made us do this countless of times in the past, when command names have changed (MD5FingerPrint is one off the top of my head).
Re: WriteStringN() extra parameter
It is better to reduce the number of commands. But search and replace would require more thought here.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum