Trailing Whitespace after continuation character results in misleading error message.

PhilHornby

Senior Member
Example (There is a single " " (space) after the "_".)

Code:
[COLOR=Blue]sertxd([/COLOR][COLOR=Red]"X"[/COLOR][COLOR=Black], _ 
       [/COLOR][COLOR=Red]"Y"[/COLOR][COLOR=Blue])[/COLOR]
Whitespace.png
 

Technical

Technical Support
Staff member
The error msg is correct. Continuation is '_<newline>' only.

Any other combination of '_' within whitespace is then a symbol, so use of '_' is no different to 'x' or 'y' and hence needs to be defined by a 'symbol' command.
 

PhilHornby

Senior Member
What on earth are you talking about?

Technical said:
The error msg is correct. Continuation is '_<newline>' only.

Any other combination of '_' within whitespace is then a symbol, so use of '_' is no different to 'x' or 'y' and hence needs to be defined by a 'symbol' command.
The whitespace was not intentional. In the original incarnation a text string was terminated by several tabs and a ;comment.

Thus:
Code:
[COLOR=Blue]sertxd([/COLOR][COLOR=Red]"some text to be formatted for readability"[/COLOR][COLOR=Blue])         [/COLOR][COLOR=Green];comment[/COLOR]
I decided to re-format it for readability, like so:

Code:
[COLOR=Blue]sertxd([/COLOR][COLOR=Red]"some text to be formatted"[/COLOR][COLOR=Black], _
       [/COLOR][COLOR=Red]"for readability"[/COLOR][COLOR=Blue])                       [/COLOR][COLOR=Green];comment[/COLOR]
That compiles successfully.

However, initially I'd left a trailing TAB after the "_" and received the INCORRECT error message, telling me that the "_" was wrong.

It's 40 years since I wrote my first program - so it didn't take me long to figure out where the error lay (in the compiler). Your primary audience - school children - may well be left scratching their heads. You can't see 'whitespace' and the error message doesn't mention it. And why is it an issue anyway?

[HR][/HR]

As a general note, why are all my problems reports met with such instant, condescending responses?

In the 30+ years I spent troubleshooting technical issues for some of the UK's largest companies, I never encountered remotely anything like it.

Also, why do you hide behind "Technical"? Who am I speaking to?

Can I remind you I'm a PAYING CUSTOMER (unless you're about to start giving Picaxe's away).
 

Technical

Technical Support
Staff member
We can assure you that there was no intention to be condescending. In PICAXE BASIC the line continuation symbol recognised by the compiler is a specific sequence of characters, underscore then newline. It is not underscore by itself.

So underscore by itself (ie surrounded by whitespace) is quite simply not the line continuation symbol as far as the compiler is concerned. The compiler therefore parses an unknown symbol, the single character '_' by itself, and hence does not know what to do with it. It does not match any known symbol. Hence the error message displayed - it has found a symbol called '_' that it cannot handle.
 

westaust55

Moderator
@PhilHornby

The topic of line continuation has been discussed before, such as:
http://www.picaxeforum.co.uk/showthread.php?20690-Splitting-Long-Lines&highlight=underscore
wherein I had suggested a better description might be:
_ [Enter] (whitespace-underscore-Enter) as line continuation for splitting long lines
and
Continuation characters should work with a space before them, do when I try it, but must be the last character on a line. If there are trailing spaces or tabs that might be causing an issue.
Note also that while the PICAXE Manual2 (V7.9.2) at page 6 mentions a colon ( : ) as a newline character, as an undocumented left over from earlier times (for compatibility with old program listings) a space is typically also treated as a newline in many circumstances. The PE does its best to figure out when a space does mean a new line but (at least in PE5) could sometime fail.

Thus not withstanding Technical's explanation about the [underscore] [space] being treated as an undefined symbol,
the trailing space might otherwise have be seen as a newline character, again resulting in a syntax error.
 

nekomatic

Member
The compiler therefore parses an unknown symbol, the single character '_' by itself, and hence does not know what to do with it. It does not match any known symbol. Hence the error message displayed - it has found a symbol called '_' that it cannot handle.
So the behaviour is explained, and the error message is logical... but it is still misleading, because it doesn't help the average user figure out what's wrong.

Is there any reason the compiler couldn't consider underscore followed by optional whitespace then newline to be a continuation symbol? Would that break any existing code?
 
Top