DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to treat group propertys of float as float?

There is a group names "groupname" with a extra property (Zusatzeigenschaft) named "X" of type float64. It's value is  "1,5"
Try this script:

msgbox GroupPropGet(GroupIndexGet("groupname") ,"X")
msgbox CStr(GroupPropGet(GroupIndexGet("groupname") ,"X"))
msgbox CDbl(CStr(GroupPropGet(GroupIndexGet("groupname") ,"X")))
msgbox CDbl(GroupPropGet(GroupIndexGet("groupname") ,"X"))

The last two outputs are different and wrong!
I need a (SUD-)dialog to edit a propperty of type float. For this I have to convert it to string and after editing to convert back  to float.

0 Kudos
Message 1 of 3
(3,179 Views)

I guess the problem is the decimalsign (dot / comma)

Try this little function

Option Explicit

msgbox GroupPropGet(GroupIndexGet("groupname") ,"X")
msgbox CStr(GroupPropGet(GroupIndexGet("groupname") ,"X"))
msgbox StringToFloat(CStr(GroupPropGet(GroupIndexGet("groupname") ,"X")))

'''Function to convert a string to a float value
Function StringToFloat(sInput)
  Dim sDecimalCharacter
  Dim sTempValue
 
  If IsNumeric(sInput) Then
    'Determine the decimalsign (which depends on the regional settings)
    sDecimalCharacter = Mid(1.1, 2, 1)

    If Instr(sInput, ".") > 0 Then
      sTempValue = Replace(sInput, ".", sDecimalCharacter)
    Else
      sTempValue = Replace(sInput, ",", sDecimalCharacter)
    End if

    StringToFloat = CDbl(sTempValue)
  Else
    StringToFloat = Null
  End If
End Function

0 Kudos
Message 2 of 3
(3,169 Views)
Tanks for answer. Yes, the problem is the decimalsign. I found a simple solution. It's embarrassing but it works:
use of "val"-function instead of "CDbl"-function and everythink is going to be alright.

("val" is a old function of Diadem, CDbl is a VBscript -function)

Martin
0 Kudos
Message 3 of 3
(3,166 Views)