Bug in PRINT <positive number>?

Windows specific questions.
Post Reply
BasicJan
Posts: 46
Joined: Aug 30, 2005 20:09
Location: Netherlands

Bug in PRINT <positive number>?

Post by BasicJan »

If a positive number is converted to a string (STR$(<positive number>) or printed (PRINT <positive number>) in QuickBasic a space is placed before the number.

In FreeBasic no space is added if a positive number is converted to a string (STR$). However, if a positive number is printed, a space is still added!!

Try

PRINT "TEST";100

Was this meant to behave like this, or should there be no space, like the STR$-statement?
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

Yes, it's meant to be like this.

Regards,
Mark
urger
Posts: 32
Joined: Jul 30, 2005 22:44

Post by urger »

This was deliberately changed in FB.
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Post by 1000101 »

Why?

Just to break things and require people to check for lead spaces?

Stupid reasons people.
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

STR$ works that way since release 0.0, that's listed in the wiki docs as well: http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgStr
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

It was a design decision v1ctor made. I personally don't care about leading spaces for non-negative numbers.

I guess that v1ctor found this leading space for STR$ annoying and therefore removed it in FB to get rid of the need of the "LTRIM$(STR$(num%))" stuff. However, the leading space is kept when printing numbers to ensure that the output isn't broken when compiling old QB sources with FB.

Regards,
Mark
JJ2005
Posts: 30
Joined: Sep 29, 2005 14:41

Post by JJ2005 »

mjs wrote:It was a design decision v1ctor made. I personally don't care about leading spaces for non-negative numbers.

I guess that v1ctor found this leading space for STR$ annoying and therefore removed it in FB to get rid of the need of the "LTRIM$(STR$(num%))" stuff. However, the leading space is kept when printing numbers to ensure that the output isn't broken when compiling old QB sources with FB.

Regards,
Mark
Personally I prefer no spaces, and it should be consistent between screen and other outputs. Screen no, printer yes makes no sense.
Inserting a space in old QB sources would be truely cumbersome, though. Imagine a "Print a1;a2;a3" etc. statement...
Best option imho would be an "OPTION LEAD SPACES ON" (default: OFF) for those who rely on QB sources.
Post Reply