Calculation as a parameter not working

Archives Forums/BlitzMax Bug Reports/Calculation as a parameter not working

col(Posted 2013) [#1]
I have some code that calculates a value as a paremeter and its doesn't work...

If _CaretPixelY < 0
	AdjustTopLine(hWnd,0,_CaretPixelY / _LineHeight)
	SendMessageW(GetParent(hWnd),CEM_MOVEVSCROLL,hWnd,_CaretPixelY / _LineHeight)
EndIf


BUT this works
If _CaretPixelY < 0
	Local Amount = _CaretPixelY / _LineHeight
	AdjustTopLine(hWnd,0,_CaretPixelY / _LineHeight)
	SendMessageW(GetParent(hWnd),CEM_MOVEVSCROLL,hWnd,Amount)
EndIf


You see the last parameter in the SendMessageW function... the _CaretPixelY / _LineHeight ... if I leave the function as it is then 0 is sent to the receiving window procedure but if I calculate the value and stick it in a local variable ( 'Amount' as shown in the extract ) then the correct value is received in the window procedure. Putting the calculation within parenthesis doesn't work either.

I'v never come across this before and its obviously part of a much larger code set, but still... the bug is real.

Anyone else seen this before?

EDIT:- I should note that the line before the SendMessageW... the AdjustTopLine method returns a value that I don't use in this section of code.


BlitzSupport(Posted 2013) [#2]
Are _CaretPixelY or _LineHeight floats? I'm thinking the result of the calculation would be a float if so, whereas when assigned to an integer as in your working example, the result will be an int...


col(Posted 2013) [#3]

Are _CaretPixelY or _LineHeight floats?



Hiya,

Nah, they are both integers.

I think I've isolated the termite...

If I omit the 'AdjustTopLine' line above it then it works as expected. ie the calculation is performed correctly as a parameter. The 'AdjustTopLine' returns an integer that I'm not using in this section of code ( but is used elsewhere ). This method has standard 'in only' parameters ( not Var ) and returns an integer.


col(Posted 2013) [#4]
No bug here :D

The _CaretPixelY variable is altered inside 'AdjustTopLine'

lol.

I must stop the late nights/early mornings.
4.30am ( again ) and I'm getting up for work at 7.30 :P