-->
Page 1 of 2

Print stripping out spaces inside quotes

PostPosted: Mon Apr 11, 2016 4:11 pm
by Electroguard
This is an unimportant 'rainy day' sort of thing...

Code: Select allprint "Local node name:   " & localname
print "Global name:       " & globalname
print "Group name:        " & groupname
print "Local IP address:  " & localIP

I expected the above to pad the variables neatly underneath each other, but the print function is stripping out the trailing spaces that are enclosed within the quotes and causing all the variables to directly follow after the ":"

Actually, when previewing this I noticed it did exactly the same the thing unless I marked it as code.

I've subsequently found out that html also strips out the excess blanks.
Is there some way of inserting spaces to shift text to the right without inserting visble characters?

Re: Print stripping out spaces inside quotes

PostPosted: Tue Apr 12, 2016 2:48 am
by gerardwr
I use the TAB character for this, like this
Code: Select allprint "Local node name:\t" & localname

It skips to the next tab position.

Re: Print stripping out spaces inside quotes

PostPosted: Tue Apr 12, 2016 4:10 am
by Electroguard
Hi, thanks for the suggestion, but it only prints the extra characters literally, much as expected when looking at it.

I did try sending tab as chr(9) though, but that made no difference.

It seems something specifically to do with the colon, because I've found that commands which normally do accept multiple spaces inside of quote marks take the unrequested action of stripping out the excess after the colon - so it would seem to be an additional action that has been built in based on an assumption. I'm only mentioning it o avoid some head-scratching for others.
It's no great problem when you know, but a bit of a puzzle until you find out, cos my assumption has always been that all printable characters within quotes would be printed as-is.

Re: Print stripping out spaces inside quotes

PostPosted: Tue Apr 12, 2016 4:58 am
by cicciocb
It seems that the problem comes from the html part as it works properly on the serial port.
If you look at the html source (view - sources in the browser), you'll see that the spaces are there but the browser remove them.
Another fix is required.