Qbasicnews.com

Full Version: PRINT number; difference with QBasic
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The behavior of PRINT ; with numbers has always been a bit weird in QBasic, the freeware interpreter that used to come with DOS. (I dunno how it is in QuickBasic). Unfortunately, using STR$ is not enough to get a compatible behaviour between QBasic and FreeBasic.

I like to PRINT a lot of stuff on one line, with ; to just keep going.
When numbers are involved, I observe this behavior:

PRINT number;
in QBasic: space - number - space
in FreeBasic : space - number

PRINT STR$(number);
in QBasic : space - number
in FreeBasic : number
Yes, it is well known. v1ctor hated to have to do ltrim$(str$(n)) so he removed the leading space, as a "feature".
The FB compiler is written in FB and dpends on the feature, so to change this behavior would require to adapt 65000 lines of code.
You can always:

Code:
Function int2StrQb (number As Integer) As String
   Dim res As String
   If number < 0 Then
      res = Str$ (number)
   Else
      res = " " + Str$ (number)
   End If
   int2StrQb = res
End Function

' ... same for single, double, short, whatever

... and use it instead of Str$ for printing.