GetAsNumber(text) function returns negative result if hyphenated text

Discussion created by itraining on Aug 17, 2015
Latest reply on Aug 17, 2015 by mardikennedy

Heads-up for other developers. The negative result returned by the GetAsNumber(text) function in the example shown below caught me by surprise. If you were not aware, hopefully you can anticipate the result after reading this post.


TableOccurence = Plugin

Field Name = Plugin::VersionFunctionAsText

Field Contents = TrFile_Version ( "-GetVersionString" )


Script with 3 Set Variable script steps:

$FunctionText = Plugin::VersionFunctionAsText is populated with the result TrFile_Version ( "-GetVersionString" )

$FunctionResult = Evaluate ( $FunctionText ) ) is populated with the result Troi File Plug-In 8.0.3

$Version = GetAsNumber ( $FunctionResult ) is populated with the result  -8.03


I understand the GetAsNumber function extracts the numerical information and drops the text information but I did not know hyphens before the number would be included as a negative sign. After troubleshooting a script returning an unexpected negative result, I know better.

This text containing a hyphen is not listed as an example in the FileMaker 14 help:





Michael Richards

Brisbane (Australia)