Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:27 13 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Print

Author Message
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 06:48pm 06 Apr 2015
Copy link to clipboard 
Print this post

Hi

Currently working a project that uses serial to communicate. During the testing I noticed that a number sent to the serial port with Print #1, XX gets a space padded to the front. I checked the manual and this is by design "When printed, a number is preceded with a space if positive or a minus (-) if negative"
The negative I get but the space I don't get please could somebody explain as to why it is done this way. (Not being negative just curious)
My serial output looks like this 33, 47, 76 etc.....
So this is a easy fix
Value$=STR$(xx)
Print #1, Value$

Of course the same applies when printing to the console

Regards
Jman


 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 08:13pm 06 Apr 2015
Copy link to clipboard 
Print this post

Having the space for positive numbers makes it easier to align columns when there is a mix of positive and negative numbers.

I usually use STR$() (or FORMAT$ depending on the device) as you did.

Jim
VK7JH
MMedit
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3285
Posted: 04:26am 07 Apr 2015
Copy link to clipboard 
Print this post

This is because I slavishly followed Microsoft BASIC and other implementations of the era. The space has annoyed me also but I try to not to change a feature of the language just because I do not like it.

Geoff

EDIT: The requirement for the space is also documented in the ANSI Standard for Full BASIC (X3.113-1987) or ISO/IEC 10279:1991 (for what that is worth).

P.S.S. I guess that your question really was asking about the utility of this "feature" and I believe that TassyJim has the right answer. Edited by Geoffg 2015-04-08
Geoff Graham - http://geoffg.net
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025