Multi line comment without using /' ... '/

Post your FreeBASIC tips and tricks here. Please don’t post your code without including an explanation.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Multi line comment without using /' ... '/

Postby AGS » Sep 10, 2010 1:48

Single line comment => ' followed by a bunch of characters (ends at newline)
Multi line comment => /' followed by a bunch of lines (ends at '/, can be nested)


Or you can use line continuation to turn text into comment

Code: Select all

Dim x As Integer = 88

_ This is an example of using
_ line continuation to turn 
_ lines of text into a
_ multiline comment without
_ using comment syntax
_ make sure there is some whitespace
_ between the underscore and the
_ first non-whitespace character

Print x



I know, it's kinda silly...
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Postby 1000101 » Sep 10, 2010 5:42

I'm surprised you don't get a syntax error. That looks like a compiler "feature" to me. :P
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Sep 10, 2010 12:37

Whooa! Nice discovery dude!
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Postby anonymous1337 » Sep 11, 2010 3:22

wat no way l33t h4x!!!!!1!1111

???
jevans4949
Posts: 1148
Joined: May 08, 2006 21:58
Location: Crewe, England

Postby jevans4949 » Sep 11, 2010 11:39

Comments are allowed after a line continuation character. That's documented.

What you have here is a line continuation with nothing in front of it. So the compiler is compiling a multi-line null statement.
djsfantasi
Posts: 87
Joined: May 21, 2010 17:38
Location: Massachusetts, USA
Contact:

Postby djsfantasi » Sep 11, 2010 14:15

Nice hack, but wouldn't it just be as easy to use the single line character? And the single quote doesn't require shifting into uppercase.

Code: Select all

Dim x As Integer = 88

' This Is an example of NOT using
' Line continuation to turn lines
' of text into a multiline comment
' by using comment syntax

Print x

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest