![]() |
Forum Index : Microcontroller and PC projects : Print
Author | Message | ||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
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: AustraliaPosts: 6269 |
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: AustraliaPosts: 3285 |
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. Geoff Graham - http://geoffg.net |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |