2 Replies Latest reply on Oct 12, 2014 7:28 AM by TomHays

    set exact precision


      Hi, sorru for bothering again.


      I am wondering whether there is a way to set exact precisions in FileMaker? For example, once set the precision, even if the calculated value is an integer, it adds 0s after it. for example, set the precision as 2, while the calculation result is 1, it is desired to show 1.00 instead.


      Plus, I am wondering whether FileMaker accepts Regular Expression? If so, could you please kindly show me how?


      Thanks so much in advance.

        • 1. Re: set exact precision

          If you merely wish to DISPLAY a number to a fixed decimal precision, as distinct from actually entering the number itself thus, you can select the field and set the precision in the Data Inspector (see screenshot). For example, if you entered the number 28 in a field, the setting shown would mean it would display as 28.000000.


          Screen Shot 2014-10-12 at 5.58.56 pm.png

          • 2. Re: set exact precision

            zehang wrote:


            Plus, I am wondering whether FileMaker accepts Regular Expression? If so, could you please kindly show me how?



            Regular Expressions are not part of the FileMaker Pro toolset.


            Its built-in pattern matching is limited to Position() and PatternCount() which will find a specific string inside another string.  If your needs are very limited, it may be sufficient to use these functions in combination with other text functions, e.g. Left(), Right(), Middle(), and perhaps recursive custom functions.  It won't be as good as real Regular Expression functions.


            There are choices of FileMaker plug-ins for adding Regular Expression matching or similar functionality.  These plug-ins usually do this by adding access to a full programming language that has Regular Expressions or similar functionality. 


            I can provide an example of using the pattern matching capabilities of the LuaFy FileMaker plug-in that provides the Lua scripting language. (Unlike popular stand-alone languages such as PHP or Java, Lua is a small scripting language created specifically for the purpose of being embedded in a host program.) I am the developer of the LuaFy plug-in.


            Assuming that you have the LuaFy plug-in installed and gain access to the new functions provided by LuaFy, the FileMaker calculation


            LuaFy_CallFunction("string.match"; "We have 42 products in stock."; "%d+ %a+")


            will return the value "42 products".

            The "%d+ %a+" string is written in Lua's native pattern matching language which provides most of the functionality of Regular Expressions.  %d+ means find one or more digits.  %a+ means find one or more letters. "%d+ %a+" thus matchines one or more digits followed by a space followed by one or more letters. LuaFy also comes with an additional library of functions (LPEG) that provide a more elaborate regular expression grammar.