It is currently Thu Nov 21, 2019 6:26 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: WriteStringN() extra parameter
PostPosted: Sat Aug 31, 2019 9:29 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5856
Location: Wales, UK
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WriteStringN() extra parameter
PostPosted: Sat Aug 31, 2019 10:07 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 373
Location: Germany
Related: WriteString(): Add flag to set the line ending char

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: WriteStringN() extra parameter
PostPosted: Sun Sep 01, 2019 2:45 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 935
Sicro wrote:
Dude has already written in this topic why this wish is unnecessary.


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


Top
 Profile  
Reply with quote  
 Post subject: Re: WriteStringN() extra parameter
PostPosted: Sun Sep 01, 2019 5:43 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 373
Location: Germany
Josh wrote:
Dude has already written in this topic why this wish is unnecessary.
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:
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'.
Such a command / flag would be good, too.

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: WriteStringN() extra parameter
PostPosted: Sun Sep 01, 2019 11:23 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1675
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?
Code:
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:
Macro WriteStringCRLF(File, Text, Format = #Null)
  WriteString((File), Text + #CRLF$, (Format))
EndMacro

Macro WriteStringLF(File, Text, Format = #Null)
  WriteString((File), Text + #LF$, (Format))
EndMacro

_________________
On GitHub: PB Includes - IDE Tools - Color Themes


Top
 Profile  
Reply with quote  
 Post subject: Re: WriteStringN() extra parameter
PostPosted: Sun Sep 08, 2019 6:18 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 373
Location: Germany
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:
PB help wrote:
To write a string including a newline sequence, use the WriteStringN() function.

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.

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().

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: WriteStringN() extra parameter
PostPosted: Sun Sep 08, 2019 10:04 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 394
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.

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.

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).


Top
 Profile  
Reply with quote  
 Post subject: Re: WriteStringN() extra parameter
PostPosted: Sun Sep 08, 2019 11:04 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3121
Location: Boston, MA
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye