Xojo does not seem to know how to calculate in DrawControlInLayoutEditor

Xojo does not seem to know how to calculate in DrawControlInLayoutEditor

I am guessing its Xojo script at work in this event ?

But it basically does not know how to calculate 1 - 1 since it thinks 1 - 1 is 1 but of course it should be zero.

var reminder as Double = 1.0

if lowLimit > 0.0 then  // lowLimit is also type double
  g.DrawObject(a)
  
  g.DrawingColor = &cFF0000
  g.DrawText(Str(reminder), 20, 20) // Prints 1
  
  g.DrawText(Str(lowLimit), 20, 32) // Prints 1
  
  reminder = 1.0 - lowLimit
  
  g.DrawText(Str(reminder), 20, 44) // Prints 1 ?? should be 0 !!!!
  
end if

It actually seems to know how to calculate it just does not know how to assign again to the reminder variable for some reason…

Since if I put it in tmp variable instead then it calculates

var reminder as Double = 1.0

if lowLimit > 0.0 then
  g.DrawObject(a)
  
  g.DrawingColor = &cFF0000
  g.DrawText(Str(reminder), 20, 20) // Prints 1
  
  g.DrawText(Str(lowLimit), 20, 32) // Prints 1
  
  var tmp as Double = 1.0 - lowLimit
  
  g.DrawText(Str(tmp), 20, 44) // Prints 0
  
end if

All a bit disturbing…

And if we test one more… then we can see how the assignment fails again to reminder:

var reminder as Double = 1.0

if lowLimit > 0.0 then
  g.DrawObject(a)
  
  g.DrawingColor = &cFF0000
  g.DrawText(Str(reminder), 20, 20) // Prints 1
  
  g.DrawText(Str(lowLimit), 20, 32) // Prints 1
  
  var tmp as Double = 1.0 - lowLimit
  reminder = tmp

  g.DrawText(Str(reminder), 20, 44) // Prints 1 but should be 0 since tmp is 0
  
end if

I’ve did a quick test and It seems “reminder” variable name is colliding somewhere, internally. Does it works if you rename it?

No that was the first thing I tried to rename it. (Renamed it to reminderX)

I also tried changing it from double to single.

But same thing.

I think its because it is under the if, I can assign value to it outside of the if statement but not inside. (as crazy as that sounds)

That’s odd, I’ve tried to rename “reminder” to “asdf” and it seems to be working fine:

So you actually were able to reproduce it ? with the name reminder ?

Maybe reminderX is not good enough renaming…

Anything starting with REM causes the issue.

2 Likes

Super strange for sure !

Thanks for narrowing it ! I will rename it properly.

1 Like

I guess it takes lines starting with that variable name as REM comments.

Issue #72004

Thank you!