11 Replies Latest reply on Nov 23, 2009 8:59 AM by philmodjunk

    Need a button to auto format data in a field?

    jamesdalbright_1

      Title

      Need a button to auto format data in a field?

      Post

      I use FMP 9 Advanced for MAC and I would like to know how to set up a button that will automatically highlight the contents of my News Articles text field and change the characters to Ariel, Plain, 16. Thanks.

        • 1. Re: Need a button to auto format data in a field?
          philmodjunk
            

          define a text field, Highlight

           

          Script for your button:

           

          If [IsEmpty(table::Highlight) ]

            Set Field [Table::Highlight; "Highlight"]

          Else

            Set FIeld [Table::Highlight; "" ]

          End IF

           

          Format your field with a conditional format expression:

           

          Not Isempty(table::Highlight)

           

          Select a fill color to highlight the field.

          Select the text font type, style and size you want.

           

          Now click the button once to see the text style change. Click it a second time to undo the change.

          • 2. Re: Need a button to auto format data in a field?
            jamesdalbright_1
              

            I was not able to do this. I started by selecting New Script; If, then in the Specify Calculations window I chose IsEmpty from the functions window and then I selected the table Related News Articles Table and then double clicked on News Article field in the list of fields. I came up with:

            If [IsEmpty (Related News Articles::News Article)] 

            Then I moved Set Field over and in the Edit Script "New Script" window I opened the Specify window next to Calculated result. I then double clicked on the News Article field in the Related News Article Table and it place it in the box below. I then typed a semicolon after the News Article added a space and typed "Highlight". When I clicked the Ok button I got an error message: An operator (e.g. _+,-,* is expected here. Here is what it looked like when I got the error message: Related News Articles::News Article; "Highlight". I don't know how to get it to accept it. Can you instruct me as to how to do this?

            What I want to do is to change the font of the news articles that I add to the News Article Field to Arial, 16 and remove any bold, italic and underlining formatting resulting in just plain text. Thanks 


             

            • 3. Re: Need a button to auto format data in a field?
              philmodjunk
                

              First Item: You seem to have skipped the first step:

               

              define a text field, Highlight

               

              You need this new field in order for this to work. You don't want your set field to replace the current contents of Related News Articles::News Article with the word "Highlight" do you?

               

              Second Item:  Creating the Set Field Step

              With regards to set field, this is a frequent beginner's mistake. You have two specify buttons. Click the upper specify... button (Specify Target Field) and select the new Highlight field. Click OK and then click the second specify... button (Calculated Result) and enter the expression to the right of the semicolon and click OK. Don't enter the semi-colon, you'll find that filemaker adds that for you.

               

              • 4. Re: Need a button to auto format data in a field?
                jamesdalbright_1
                   Thanks. I'll work on it. 
                • 5. Re: Need a button to auto format data in a field?
                  jamesdalbright_1
                    

                  I set up the highlight field and applied the script and when I click on it the word highlight appears and when I click on it again the word highlight disappears. What is the conditional expression that I need to change the formatting in my news article field from whatever it is to Arial, black, 16, plain using this button?

                  Outside of what you are showing me I have found that four insert text calculations including Font, Color, Size and Style that I associate with a button that targets the text field that I want to change the text formatting in works but does not have the undo or the changing theme in the button.

                  I would like to follow up with the idea that you are offering if you have the time. Thanks. 

                  • 6. Re: Need a button to auto format data in a field?
                    philmodjunk
                      

                    Go back and look at the original script example. The script does not directly modify your text field in any way. Instead, it modifies a new text field you create just for this one feature by setting it to either "highlight" or "". This field does not have to be on the layout, though I'd put it there until I've confirmed that my button and script are working. Then, I'd remove it from the layout.

                     

                    Once you have this working, select your text field where you want to see the format change and apply the conditional format to it.

                     

                    Select the field in layout mode.

                    Select Format | Conditional...

                    Click Add

                    Select "Formula Is"

                    Click Specify....

                    Change the expression to be Not IsEmpty(YourTable::HighlightField)

                    Click Ok

                    Select the text formats and fill color you want to appear in your selected field when the Highlight field isn't blank.

                    Click Ok

                    Enter Browse Mode and test

                     

                    • 7. Re: Need a button to auto format data in a field?
                      jamesdalbright_1
                        

                      I defined a field called Highlight in my news articles table and placed it on the news article layout.

                      Then I assigned the script below to a button that targets the highlight field.

                       

                      If [IsEmpty(table::Highlight) ]

                        Set Field [Table::Highlight; "Highlight"]

                      Else

                        Set FIeld [Table::Highlight; "" ]

                      End IF 

                       

                      Then I applied the not IsEmpty conditional formatting to the new highlight field and selected the fill color and text formatting.

                      When I click button the only thing that takes place is the word highlight appears and disappears in the text field. If I paste text into the field and click the button it disappears and when I click it again the word highlight appears. What have I done wrong? 

                       

                      • 8. Re: Need a button to auto format data in a field?
                        comment_1
                          

                        jamesdalbright wrote:
                        What I want to do is to change the font of the news articles that I add to the News Article Field to Arial, 16 and remove any bold, italic and underlining formatting resulting in just plain text.

                         

                        Make your button perform the Set Field[] step. Click 'Specify target field' and select the News Article field. In 'Calculated result', enter:

                         

                        TextFormatRemove ( News Article )

                         

                         

                        Note:

                         

                        1. You don't want to specify the font in the calculation. Plain text has no font attribute, and it will display in the font selected for the field in Layout mode.

                         

                        2. You can define the field to auto-enter a calculated result using the same formula; this will automatically strip formatting from the input.

                         

                        3. Selecting Undo immediately after pasting will remove all formatting from the pasted text. Another way is to hold the Option/Alt key during pasting.

                         

                         

                        I don't quite see where highlighting figures in this.

                        • 9. Re: Need a button to auto format data in a field?
                          jamesdalbright_1
                            

                           

                           I tried redefining the text field to a calculation but could not find the set field function in the function list so I inserted the TextFormatRemove (News Article) alone and when I pasted text into the field it did not change it.

                          How do I cause the field to automatically apply Arial, 16, black, plain formatting to the text when I paste it in the text field? Thanks 

                          • 10. Re: Need a button to auto format data in a field?
                            comment_1
                              

                            jamesdalbright wrote:

                            I tried redefining the text field to a calculation


                            That is NOT what I suggested. The field should be a Text field with auto-entered calculated value, replacing existing value.

                             


                            • 11. Re: Need a button to auto format data in a field?
                              philmodjunk
                                

                              We seem to have gotten way off track here over the weekend.

                               

                              The original question:

                              "I would like to know how to set up a button that will automatically highlight the contents of my News Articles text field and change the characters to Ariel, Plain, 16."

                               

                              There are two parts to my suggested solution. You have one part in place and now need to implement the second half. Now that you have a button that sets the value of a text field to either "Highlight" or blank, you need to apply a conditional format to your News Articles field that changes format based on whether or not this field is blank.

                               

                              In layout mode, select you News Articles field.

                              Select Format | Conditional...

                              Click Add

                              Change the condition from "Value is" to "Formula is".

                              Click the Specify...  button and enter: Not IsEmpty(YourTable::YourHighlightTextField) /* Specify the field being set to "Highlight" here */

                              Click Ok.

                              Click more formatting

                              Select the Ariel Font, plain, size 16

                              Click the Fill color check box

                              Click on the Color palette button to the right of this check box and select a fill color (This highlights your text field).

                              Click OK

                              Enter browse mode and test.