|
Post by digihzdata on Sept 9, 2007 10:13:56 GMT
A problem with invalid float value. I sometimes get a totaly wrong flot value like -7.45058e-008 In the GUI it all looks ok with min value, max value and number of decimals. BUT the actuall value stored is not. If i for example set: Mesh_Position_X_Float = GUI_FLOAT(EntityWindow,56,88,0.0,-100000.0,100000.0,"X",0.1,64,2,1,1,"",$00EEEEEE,$00D2D2D2,$00000000)
The VAL#=0.0 The MIN#=100000.0 The MAX#=100000.0 The DEC=2
So you think that the Mesh_Position_X_Float var should always have max 2 decimals, but this is not true. Is it a BUG???
From help: GUI_FLOAT(WIN,X,Y,VAL#,MIN#,MAX#, [LABEL$], [STEP#],[W],[DEC],[TAB],[ACT],[HELP$],[COL0],[COL1],[TCOL])
I am working on a solution for this right now anyhow. Found that in XIo.bb there is a function named Function FLIMIT#(XL_A#,XL_B#,XL_C#)
Function FLIMIT#(XL_A#,XL_B#,XL_C#) ;SIMPLE LIMITER If XL_A<XL_B Return XL_B Else If XL_A>XL_C Return XL_C Else Return XL_A EndIf EndIf End Function
This code i think needs more implementation of decimals-checking.
I have tested the following code in my program that GIVES the correct values:
Function ValidValueXlntFloat#(value#, decimals# ) s# = Sgn( value ) If value < 0.0 Then value = -value diff# = value Mod decimals Return ( value - diff ) * s End Function
To test the code call it like this in your program: Text 0,100,ValidValueXlntFloat(MyMeshPointer\x_pos#,.01 )
This will give you the correct value.
I only have to implement it in Xlnt now, but is it a good idea to put this code inside the function FLIMIT ?
|
|
|
Post by mjhszxy on Jul 28, 2008 1:39:25 GMT
|
|