Page 2 of 3
Re: StringSection / EndStringSection
Posted: Tue Jan 12, 2010 2:35 pm
by Trond
Kaeru Gaman wrote:what about some EXTRA type for the DataSection?
e.g. name it type .ss
this would lead to
Data.ss
Read.ss MyString.s
the .ss type Dataline could carry
- literal strings in DQuotes, wich will NOT be terminated with delimiters
- numbers that will directly be inserted, to be able to carry controlcodes
then datalines could look this way:
Code: Select all
Data.ss "this is the first line", #CRLF, "this is the second line", #CRLF
Data.ss "this is some text in quotes:", #DQUOTE, "quote me", #DQUOTE, #CRLF
Data.ss "and all the text belong to the same string!", #StringTerminate
maybe that would solve
almost the same
and be far easier to implement to IDE and Compiler...
You can't expect people to manually null-terminate their strings in a BASIC language, it's just
not rightâ„¢.
If people want to do that then they can use inline asm, which looks really clean in my opinion:
Code: Select all
Readme.s = PeekS(?MyString)
DataSection
MyString:
!CRLF equ 13, 10
!db "this is the first line", CRLF, "this is the second line", CRLF
!db 'this is some text in quotes:"quote me"', CRLF
!db "and all the text belong to the same string!", 0
EndDataSection
Re: StringSection / EndStringSection
Posted: Tue Jan 12, 2010 4:48 pm
by Kaeru Gaman
okay... I think I got to take a look at the db command ...
you use " and ' mixed?
fist line: " encloses the string
second line ' encloses the string wich contains "
Re: StringSection / EndStringSection
Posted: Tue Jan 12, 2010 6:41 pm
by Marco2007
Trond wrote:
Code: Select all
Readme.s = PeekS(?MyString)
DataSection
MyString:
!CRLF equ 13, 10
!db "this is the first line", CRLF, "this is the second line", CRLF
!db 'this is some text in quotes:"quote me"', CRLF
!db "and all the text belong to the same string!", 0
EndDataSection

Holy Shit, this is great! thx!

Re: StringSection / EndStringSection
Posted: Tue Jan 12, 2010 7:43 pm
by Foz
What about a tool for generating and editing hex data lines?
Re: StringSection / EndStringSection
Posted: Tue Jan 12, 2010 7:50 pm
by Trond
Kaeru Gaman wrote:okay... I think I got to take a look at the db command ...
you use " and ' mixed?
fist line: " encloses the string
second line ' encloses the string wich contains "
Both " and ' can be used to define strings, the strings can contain the other type of quote.
Note: use of !db works in ascii mode only. For unicode, use !dw instead.
Re: StringSection / EndStringSection
Posted: Tue Jan 12, 2010 7:56 pm
by Seymour Clufley
That's much more complicated than a StringSection like I propose. I really do think there's a place for this. Of course it's not essential and it wouldn't improve our programming, but it would be very useful.
Heredoc style syntax
Posted: Thu Jan 14, 2010 10:34 pm
by greyhoundcode
Similarly, something like:
Code: Select all
Print <<<TEXT
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
TEXT;
Would make it nice and easy to work with multi-line strings. Could this, or Seymour's StringSection, be implemented by some sort of pre-processor arrangement if not as a de facto part of the language?
Re: Heredoc style syntax
Posted: Sat Jan 16, 2010 9:44 pm
by Seymour Clufley
greyhoundcode wrote:Could this, or Seymour's StringSection, be implemented by some sort of pre-processor arrangement if not as a de facto part of the language?
But that would not affect the IDE, which would "syntaxify" everything inside the StringSection - so the text couldn't contain words like "with", "and", "not", "or" etc.
I still think this would be a good addition to PB, and surely not that difficult to implement.
Re: Heredoc style syntax
Posted: Wed Jan 20, 2010 8:59 pm
by greyhoundcode
Seymour Clufley wrote:I still think this would be a good addition to PB, and surely not that difficult to implement.
+1

Re: StringSection / EndStringSection
Posted: Fri Jan 22, 2010 5:39 pm
by blueznl
Dunno, wouldn't a multiline option fix the same problem?
In CodeCaddy I supported 'terminating' line continuation characters, as well as 'leading' ones, so I could do this:
Code: Select all
Data.s
_ Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet
_ dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
_ lobortis nisl ut aliquip ex ea commodo consequat.
_ Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat
_ nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue
_ duis dolore te feugait nulla facilisi.
Isn't that pretty much the same thing?
The rules I used were:
1. when appending lines strip out comments from the lines code is appended to
2. if a line STARTS with an underscore followed by a space it will be appended to the previous line
3. if a line ENDS with an underscore preceded by a space and followed by a CR or space the next line will be added to it
It takes a little code to parse the line to fix things like " _ " but it seems to work fine. By putting the line continuation character AT THE START of the next line, processing those lines becomes very fast, and code stays quite readable.
This is NOT to open a discussion on multi line support in PB!

I just wanted to see if, when requesting a 'text section' feature, things could be made as simple as possible. My solution does not support additional CR's though... Hmm...
Re: StringSection / EndStringSection
Posted: Fri Jan 29, 2010 9:29 am
by chris319
t.s = ReadStringSection(@description)
This should not be necessary. It should be:
Code: Select all
StringSection description.s =
PureBasic is a native 32 bit and 64 bit programming language based on established BASIC rules.
EndStringSection
or StringSection description$ =
For your control characters:
/n = newline
/t = tab
BTW, this is a quotation mark "
This is a double quotation mark ""
This is an apostrophe '
http://en.wikipedia.org/wiki/Punctuation
http://en.wikipedia.org/wiki/Quotation_mark
http://en.wikipedia.org/wiki/Apostrophe
Re: StringSection / EndStringSection
Posted: Fri Jan 29, 2010 11:40 am
by Seymour Clufley
chris319 wrote:t.s = ReadStringSection(@description)
This should not be necessary. It should be:
Code: Select all
StringSection description.s =
PureBasic is a native 32 bit and 64 bit programming language based on established BASIC rules.
EndStringSection
or StringSection description$ =
Possibly, although you'd have to stipulate beforehand whether the resulting string was global, local etc. Maybe not a bad thing.
But why the = sign? We don't need that when specifying structures, for example.
For your control characters:
/n = newline
/t = tab
Why these control characters instead of the real thing(s)?
BTW, this is a quotation mark "
This is a double quotation mark ""
This is an apostrophe '
I don't know if I used those names wrongly somewhere, but I am very well-acquainted with those symbols.

Re: StringSection / EndStringSection
Posted: Fri Jan 29, 2010 2:41 pm
by Kaeru Gaman
Seymour Clufley wrote:chris319 wrote:BTW, this is a quotation mark "
This is a double quotation mark ""
This is an apostrophe '
I don't know if I used those names wrongly somewhere, but I am very well-acquainted with those symbols.

in modern english terms, ' is a quote and " is a doublequote.
http://en.wikipedia.org/wiki/Quotation_mark wrote:Quotation marks or inverted commas (informally referred to as quotes[1] and speech marks) are punctuation marks used in pairs to set off speech, a quotation, a phrase, or a word. They come as a pair of opening and closing marks in either of two styles:
single ('. . .') or double (". . .").
again showing the same korinthenkacker attitude like with the definition of "character", and even
failing.
epic fail, dude!

Re: StringSection / EndStringSection
Posted: Fri Jan 29, 2010 3:27 pm
by Kaeru Gaman
the reason is the limited keyboard of classic typewriters, thus they made only a single DQ for both, opening and closing,
and an apostrophe for use as apostrophe
and opening and closing SQ.
you would need four additional keys to add the chars $201c, $201d, $2018 and $2019 to the standard keyboard.
... and the reson for being so unkind is that
chris319 wrote:Thanks for sharing your vast wisdom.
really means
hit me harder next time
... think about that before you get cynical on people again.
Re: StringSection / EndStringSection
Posted: Fri Jan 29, 2010 5:15 pm
by blueznl
Stop it people. Flamewars don't belong here.