7 Replies Latest reply on Apr 15, 2009 7:15 AM by TSGal

    Title Case

    rsagall_1

      Title

      Title Case

      Post

      I wrote a very simple script to change the case of a field to title case. The script step is:

       

      Insert Calculated Result[Select:Clinic_Name; TextStyleAdd (Clinic_Name; Titlecase)]

       

      When I use the script debugger I can see that the text changes to title case and then changes back to the previous format.

       

      How can I get the change to stick?

       

      Thanks,

       

      Rich

       

        • 1. Re: Title Case
          philmodjunk
            

          Have you applied a different format to the field on your layout? If so, remove that format and I think you'll see what you want.

          • 2. Re: Title Case
            Orlando
              

            Hi Rich,

             

            Do you have an Auto-Enter Calculated value set on this field to format the text? This would explain what is happening as you set the field and then the Calculated value kicks in and reformats the text.

             

            If this is the case you could modify the Calculation and script slightly to not trigger when you run your script.

             

            Modify the Auto-Enter Caluclated value to:

             

            If ( IsEmpty ( $DontFormat ) ; Proper ( Self ) ; Self )

             

            And then add in a Set Variable step to set a variable $DontFormat to "1", so it will look like:

             

            # 
            Set Variable [ $DontFormat; Value:1 ] 
            Set Field [ TABLE::Clinic_Name ; Proper ( TABLE::Clinic_Name ) ] 
            Commit Records/Requests [ Skip data entry validation; No dialog ] 
            #  

             

            I would also change your Insert Calculated result to a Set Field, as it does not require the field to be on the layout and the Set Field step gives you better control without the limitations.

             

            I hope this helps.



            • 3. Re: Title Case
              rsagall_1
                

              Phil - thanks for the suggestion but that's not the problem. There is no case formatting on the field. 

               

              I should add that for entries in the field that are formatted correctly the script has no effect and that data remains formatted properly. 

              • 4. Re: Title Case
                rsagall_1
                  

                No auto calc on the field.

                 

                See my comment above about properly formatted entries.

                 

                I used the Insert Calc just in case the problem was the Set Field command. But it wasn't.

                 

                Rich

                 

                • 5. Re: Title Case
                  TSGal

                  rsagall:

                   

                  Thank you for your post.

                   

                  Your calculation and the answer provided by "Orlando" are fine.

                   

                  For testing purposes, create a calculation field with the formula:

                   

                  Proper ( <table>:: Clinic_Name )

                   

                  This should display the information you want it to appear.  If this doesn't display correctly, then please post an example.

                   

                  If this does display correctly, then replace the contents of the field with this formula.

                   

                  TSGal

                  FileMaker, Inc.

                  • 6. Re: Title Case
                    rsagall_1
                      

                    Thanks - your suggestion worked. 

                     

                    Can you explain why my approach didn't?

                     

                    Rich

                     

                    • 7. Re: Title Case
                      TSGal

                      rsagall:

                       

                      First, I'm glad you got it to work.

                       

                      Your formula is fine, and the only reason I can think of why it didn't work is if the first character follows a punctuation mark.  For example, if the contents of the field was:

                       

                      (wizard of oz)

                       

                      ...you would expect the result ot be: (Wizard Of Oz)

                       

                      However, TitleCase capitalizes the first character after a space, so the actual result would be:

                       

                      (wizard Of Oz)

                       

                      That is, the parenthesis is being evaluated for uppercase; not the "w" in wizard.

                       

                      I hope this helps.

                       

                      TSGal

                      FileMaker, Inc.