Problem in PRINTL command (Original title: Single Byref parameter is weird?)
issueid=319 13-10-2011 05:29
Member
Number of reported issues by dcromley: 6
Problem in PRINTL command (Original title: Single Byref parameter is weird?)
passed single byref parameter: x shows 0 but abs(x) shows correctly

Am I going crazy -- I thought this worked for me many times.
I even booted my computer to see if that would fix it.
I have a parameter x as Single (I use this often) and ByRef (I use this often).
But in the subroutine, x is 0 and abs(x) is correct.
  Uses "console"

  Global x As Single, y As Double
  x=1
  y=2
  Call sub1(x,y)
  PrintL x,y        
  WaitKey     

Sub sub1(ByRef x1 As Single, ByRef y1 As Double)
  PrintL "Sub1a:",x1,y1
  PrintL "Sub1b:",Abs(x1),y1
  x1 = 3
  PrintL "Sub1c:",x1,y1
End Sub
Issue Details
Issue Number 319
Project thinBasic
Category Unknown
Status Fixed
Priority Unknown
Affected Version 1.8.9
Fixed Version 1.9.1
Milestone thinBasic 1.9.0.0
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




13-10-2011 11:43
thinBasic author
Well, thanks a lot for reporting this weird problem.

Fortunately it is not related to BYREF parameter passing but is a bug in PRINTL statement
If you use debugger you will see that variable values are correct but they PRINTL representation not.

If you user STR$(...) of the value (see below example) you will see.

  Uses "console"
  
  Global x As Single, y As Double
  x=1 
  y=2 
  Call sub1(x,y) 
  PrintL x,y         
  WaitKey     
  
Sub sub1(ByRef x1 As Single, ByRef y1 As Double) 
  PrintL "Sub1a:",Str$(x1),Str$(y1) 
  PrintL "Sub1b:",Str$(Abs(x1)),Str$(y1)
  x1 = 3 
  PrintL "Sub1c:",Str$(x1),Str$(y1) 
End Sub
I will change what is wrong with PRINTL command.

Thanks again
Eros

13-10-2011 16:41
Member
Well, thanks a lot for reporting this ..
Thank YOU!.

13-10-2011 21:34
thinBasic author
OK, found.
It was not PRINTL but a special condition usage of SINGLE data type when converted to string (PRINTL has to convert a number to a string before printing it).
If you use DOUBLE or any numeric data type the bug is not present.

If you absolutely need new thinBasic Core engine right now I can attach a new version (it is 1.9.0 though)
Otherwise fix will be present in next release.

Ciao
Eros

13-10-2011 22:28
Member
Next release is fine. Thanks again, Dave

+ Reply