9 Replies Latest reply on Apr 26, 2016 2:38 PM by planteg

    Adding + sign preffix

    frantolic

      Hello everyone!

       

      Needless to say I need help.

       

      As an optometrist I'm looking to integrate filemaker in my daily workflow for tracking of patients records and ran into a problem.

       

      So hear me out...

       

      I'm trying to make field that will add "+" sign before entered nubmer if the field is greater than 0.

       

      This is the first time I'll be using custom functions so be patient with me

        • 1. Re: Adding + sign preffix
          ch0c0halic

          Add a plus sign in text before the number field and set the text object to "Hive object when:" the value in the field is <0.

          • 2. Re: Adding + sign preffix
            frantolic

            Were you reffering to HIDE object when or HIVE object when?

            • 3. Re: Adding + sign preffix
              schamblee

              I'm sure it was a typo.   The site lags sometimes, and just human error,  I proof read my own mistakes and still miss some items, it happens when you read / answer several post. 

               

              I would use value < 1 to hide, I consider 0 even and below zero a negative.  What works best for you.

              • 4. Re: Adding + sign preffix
                frantolic

                Ok, I get it.

                 

                But that's not what I want actually...

                 

                I want FileMaker to add preffix when I type the number.

                 

                Something like this:

                 

                I enter "2", FileMaker populates that field with "+2.00"

                 

                Only one thing is missing, that plus sign.

                • 5. Re: Adding + sign preffix
                  beverly

                  format as "currency" and use "+" instead of "$"?

                  https://www.filemaker.com/help/14/fmp/en/html/edit_layout.10.41.html

                  you can show nothing if the field is 0

                   

                  I guess the question is display or change field? If the value needs to "appear" only, then use the number format.

                  beverly

                  • 6. Re: Adding + sign preffix
                    frantolic

                    Nice approach but still not what I'm looking for because I need a field for dioptres. So when type "-2" in the result should be "-2.00" and when I enter "+2" result should be "+2.00"

                     

                    With your aproach my negative numbers are listed as "+-2.00"

                    • 7. Re: Adding + sign preffix
                      keywords

                      Try using an auto replace calculation, so that when the data is entered it is immediately replaced with the formatted version. Something like:

                      Let ( [

                         rawData = Self  //this will be whatever is entered by the user

                        ; decimals = ".00" //you might need extra conditions if other than .00 is possible

                        ; formatted = filtered & decimals  //this concatenates the above two lines

                      ] ;

                      formatted  //this is the result in the field

                      )

                       

                      To use this approach you must make sure you uncheck "Do not replace existing value" for the auto enter option.

                      • 8. Re: Adding + sign preffix
                        beverly

                        thanks, more info provided. I might make a text field with auto-enter and have it as the display, so that the number field can be used for entry. Auto-enter with the desired formatting using build-in functions.

                        beverly

                        • 9. Re: Adding + sign preffix
                          planteg

                          Hi,

                           

                          I just made a test database: I created two fields in a table, a number field and a text field. The number field options was set to validate Strict Data Type: Numeric Only. If I type +33 in the field, this is acceptable as a number. This is one way to go, without any handling of the data. I admit that entering + in a number field is not natural, but since optometrist will use the solution, that may do it.

                           

                          If not, you may attach  a script on OnObjectScript for that field that would add a + if the number is positive and a + is not the first character.