8 Replies Latest reply on Aug 17, 2010 8:49 AM by philmodjunk

    Conditional Formatting combined with Script Run button problems

    jebber6685

      Title

      Conditional Formatting combined with Script Run button problems

      Post

      I have a funny thing occuring and I cannot figure out what is going on.

      Here is what I want to do... I want to create a "flashcard" type of file such that I look at a picture of an animal and then mentally try to recall its name. I would then click a button and a text field that is normally hidden will allow the name to be shown.

       My plan was to accomplish this by creating a Name text field with normally text color black and field fill color also black. That way, under normal conditions ( looking at animal picture) the animal name would not be visible.

      I then created a Global Text field with the word "Yes" in it. I then created a text field called SHOW. I then created a copy paste script that will copy the contents of Global field ( Yes) into the SHOW field.

      I then created a Button called Show Name. I then made this button Perform Script the Copy Paste script.

      I then created a conditional Formating of the Name field such that it is a { formula is California Sea Life DB::Show = "Yes" } and then made the conditional formating for the field Fill White when the the SHOW field has "Yes" in it.

      But a really funny thing happens. When I click the Show Name Button, "yes" is copied into the Name field and nothing is copied into the SHOW field.

      What is occuring here? What have I done wrong?

      Any help here would be greatly appreciated.

      I have FMPro Advanced 10.0 v3 with OS - Windows Vista

        • 1. Re: Conditional Formatting combined with Script Run button problems
          fitch

          You have described what your script is intended to do. Now let's see the actual script.

          • 2. Re: Conditional Formatting combined with Script Run button problems
            jebber6685

            Finch,

            I do not know how to insert images, so here is the script;

            I found a simpler script iwth the use of Insert Text. Here is the script;

            Insert Text[Select;California Sea Life DB::Test2;"Yes"]

            With Select Entire Content and Go To Target Field both checked.

            • 3. Re: Conditional Formatting combined with Script Run button problems
              philmodjunk

              What's the expression you use for your conditional format?

              If you temprorarily remove the conditional formatting so that the text in the field is readable, do you see the text you expect?

              I'd use set field instead of Insert Text, by the way. Though what you describe should work OK, the "insert" script steps only work if the field is present on the layout and you don't have to place the field you set to "yes" anywhere on the layout if you use Set Field instead.

              • 4. Re: Conditional Formatting combined with Script Run button problems
                fitch

                1. It's Fitch.

                2. Test2 is neither Show nor Name. It's tough to diagnose the problem if the description doesn't match the example.

                3. You've experimented with Copy/Paste and Insert Text, but a more reliable method is Set Field. This script step does not require that the field even be on the layout.

                4. I don't see the point of the global field if you're always going to set the show/test field to "yes." It makes more sense to set it to a fixed value as in your last post.

                It seems to me the only issue is whether the field targeted in your script matches the field in your conditional formatting formula.

                • 5. Re: Conditional Formatting combined with Script Run button problems
                  jebber6685

                  OK, what I did was abandon the global field and cut paste  idea when I discovered the Insert Text Script. Now I have created a field called Insert Text Field.

                  I then created a script called Insert Yes which is an Insert Text script. So here is what this simple script is;

                  Insert Text[Select;California Sea Life DB::Insert Text Field;"Yes"]

                  Select Entire Content is checked and Go to Target Field is checked. The Specify Field is Insert Text Field. The Specify is Yes.

                  I then created a button that will Perform Script. The script to perform is the Insert Yes scrtipt described above.

                  So at this point, the button works fine. When pushed, the word Yes appears in the Insert Text Field.

                  So now I go and creat a Conditional Formating for Name. "Name" is a text field of the California Sea Life that I am working with.

                  The Condition is [ Formula is California Sea Life DB::Insert Text Field = "Yes" ] Format is Fill Color

                  Fill Color is checked and the fill color white box is selected.

                  So the ideas is that when I push the button, it will paste Yes into the Insert Text Field and then this will trigger the Conditional Formating to turn the color of the Name field from the std black to now white so that the black text will appear.

                  But what actually happens is that when I push the button, nothing happes to the Insert Text Field but Yes replaces the name of the fish in the Name field and nothing happens with the color of the Name field. If I manually type Yes into the Insert Text Field, the Name field then changes to White per the Conditional Format.

                  So what the heck could be happening?

                   

                  • 6. Re: Conditional Formatting combined with Script Run button problems
                    fitch

                    You might try adding a Commit script step after inserting the text.

                    (As Phil and I have suggested, Set Field is generally best practice unless you have a specific reason to use Insert Text.)

                    Now, you first say that when you click the button, the word Yes appears in the IT field.

                    But then you say after you set up conditional formatting, the script no longer sets the IT field. That cannot be a cause and effect, there's something else going on here that we don't know about.

                    If you want to send a copy to <tom@fitchandfitch.com> I'll have a look at it.

                    • 7. Re: Conditional Formatting combined with Script Run button problems
                      fitch

                      Well, that was perplexing. Jeff, in the file you sent, it was behaving as you described after all: the field specified as the target in Insert Text was not getting the text, it was inserting the text into another field. Very strange.

                      I experimented with the script a bit, and then finally I went and changed some of the layout options. Then it started working! To verify, I downloaded the file again; went straight to layout options; changed nothing!; clicked OK; script works! Very, very strange. Makes me wonder if there could be file corruption.

                      At any rate, listen: don't use Insert Text. Use Set Field. A big advantage is that the field you're setting (the Yes field) doesn't even have to be on the layout. You will still probably want to add a Commit step at the end.

                      • 8. Re: Conditional Formatting combined with Script Run button problems
                        philmodjunk

                        I've had a couple of cases, either personally or when helping someone here where a given layout stopped putting the cursor where a script or layout setting (ie. tab order) specified it should go. Each case traced back to a corrupted layout. I've had pretty could success with just replacing the layout instead of replacing the entire field when this happens.

                        Definitely wouldn't hurt to run a recover on the file and see if any problems are found just to be on the safe side. Best practice is to replace a damaged file with an undamaged copy instead of using a recovered copy if it is at all possible to do so.