'Here-Documents' for easier multilinestrings to avoid #CRLF$
Posted: Sun Dec 02, 2007 3:32 pm
Hello!
I'm currently working with CGI/Perl when I have this idea. Here-Documents allow the coder to build multi-line strings without \n etc.
In Perl, there are 2 possibilities to build a string with line breaks:
In Perl, TEXT is a string terminator that tells the interpreter where the multi-line ends. You can name the string terminator as you want.
In PureBasic, this could be a possibility:
My intention is to avoid #CRLF$ all the time. Have you ever built a MessageRequester() with a veeery long text? I have and many of those requesters contained line breaks.
With Here-Documents in PureBasic you might build also MessageRequester() or TextGadget() in an easy way.
If this feature will be implemented, we can discuss together, how we will do it.
This could be a possibility:
You can imagine that << is the place where the following string should be inserted. The text itself, surreounded by duoble-quotes can be handled as usual, so it is still possible to insert variables, etc.
As I said, there are many opportunities where this feature could be helpful. Currently I'm working with CGI/Perl and so on. So I need to work with HTTP-Requests too and this feature could help me in this special situation. But also to fill gadgets and requesters, as well as variables, this feature would be helpful.
I hope you understand what my intention is.
I'm currently working with CGI/Perl when I have this idea. Here-Documents allow the coder to build multi-line strings without \n etc.
In Perl, there are 2 possibilities to build a string with line breaks:
Code: Select all
$string="Hello World!\n\nThis was an empty line\n4th line\n5th line...":
$string=<<TEXT;
Hello World!
This was an empty line
4th line
5th line...
TEXT
In PureBasic, this could be a possibility:
Code: Select all
Define string$="Hello World!"+#CRLF$+#CRLF$+"This was an empty line"+#CRLF$+"4th line"+#CRLF$+"5th line..."
Define string$=<<"Hello World!
This was an empty line
4th line
5th line..."
With Here-Documents in PureBasic you might build also MessageRequester() or TextGadget() in an easy way.
If this feature will be implemented, we can discuss together, how we will do it.
This could be a possibility:
Code: Select all
MessageRequester("Multiline Information", <<"This is a demonstration
of how to use here-
documents in PureBasic.
Thanks for reading.", #MB_ICONINFORMATION)
TextGadget(#PB_Any, <<"This is a complex example of multiline strings
that should contain variables.
My name is "+name$+<<" and
I'm "+Str(age)+<<" years old.")
As I said, there are many opportunities where this feature could be helpful. Currently I'm working with CGI/Perl and so on. So I need to work with HTTP-Requests too and this feature could help me in this special situation. But also to fill gadgets and requesters, as well as variables, this feature would be helpful.
I hope you understand what my intention is.