Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PRINT number; difference with QBasic
#1
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
Reply
#2
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.
Antoni
Reply
#3
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.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)