Splitting Long Lines

Armp

Senior Member
"Added _\n (whitespace-underscore-newline) as line continuation for splitting long lines"

I tried this in PE 5.5.0 but get Error: Unknown symbol - _ ?
 

nick12ab

Senior Member
I couldn't find any references to using in PICAXE Manual 1 or in PICAXE Manual 2. I get a syntax check pass when I only use the underscore (_) much like in Visual Basic .NET and probably lots of other programming languages too.

So use '_' instead of '_\n' to continue a long line onto another line. Alternatively, you can use the "Wrap Long Lines" option in the Options dialog on the Editor tab instead.
 

Armp

Senior Member
It's in the Revision History for PE 5.5.0 Nick..
5.5.0 Added 18M2+ support Updated help files
Serial Terminal now uses fixed width font
Added 'copy for forum' menu (adds
Code:
 tags to copied text) 
Updated compilers to v2.2 
Added _\n (whitespace-underscore-newline) as line continuation for splitting long lines 
Corrected issue with calibfreq command on negative values for M2 parts[/QUOTE]
 

nick12ab

Senior Member
It's in the Revision History for PE 5.5.0 Nick..
Ok then. Just using _ works but _\n doesn't work. This is because \n means you press enter and not that you type \n since it does say whitespace-underscore-newline and not whitespace-underscore-backslash-n.

ADDED: In many programming languages, \n is used to denote a new line so it's likely that "_\n" is how the line continuation is implemented in Programming Editor's source code.
 
Last edited:

westaust55

Moderator
Within the PICAXE Programming Editor, "\r" and "\n" are still valid controls

"\r" is the equal of CR or 13
"\n" is the equal of LF or 10

example:
Code:
for b0 = 1 to 255
 serout 3,N2400,("Hello PICAXE Forum ***\r\n")
next b0
Note that the control command goes within the string quotes whereas 13, 10 or CR, LF are outside the string quotes

but adding " _\n" within a string is the same as "_",LF
 

Technical

Technical Support
Staff member
In the release notes \n is just visual notation for newline, as it is 'invisible'

Basically if you end a line with _
it will 'cancel out' the following newline, so that the two lines appear to the compiler to be one single long line
 

westaust55

Moderator
Thank you for the clairification Techncial.

So for others, by way of example, this code will work:

Code:
FOR b0 = 1 to 100
 SEROUT 7, N2400, ("Hello world", _
 " more text here", #b0)
NEXT b0
Since \n already exists as a newline feature which is inserted within a test string, and keyboards usually have the key "Enter" (or [Enter] )
might it be better to suggest revised working as:

Added:
_ [Enter] (whitespace-underscore-Enter) as line continuation for splitting long lines
 
Top