7 Replies Latest reply on Jul 29, 2011 8:40 AM by philmodjunk

    Script Problem - Anyone can help?

    DummyRabbit

      Title

      Script Problem - Anyone can help?

      Post

      I have 2 date field (Date1 & Date2) and 2 Scripts (Script 1 & Script 2)

      Database name as Database

      I want to create a new script (Main Script)

      Same Date - Run Script 1

      Different Date - Run Script 2

      I  created a Main Script to decide to run Script 1 or Script 2

      Problem: No matter The date is same or different, it still run only script 1

      Is there any problem to my script?Help check below, I think the script shouldn't be written like this, but this is only what i can think of, please help.

      Main Script details:

      -----------------------------------------------------------------------------------------------------------

      If [Database::Date1 = Database::Date2]

          Perform Script ["(Execute) Script 1"]

          Exit Script

      End If

      If [ Databse::Date1 ≠ Database::Date2]

         Perform Script ["(Execute) Script 2"]

         Exit Script

      End If

      ------------------------------------------------------------------------------------------------------------

        • 1. Re: Script Problem - Anyone can help?
          juancardona

          Simplify your script

          If [Database::Date1 = Database::Date2]

              Perform Script ["(Execute) Script 1"]

          Else

              Perform Script ["(Execute) Script 2"]

          End If

          • 2. Re: Script Problem - Anyone can help?
            rjlevesque

            You have no "Else" comparison command to complete your script set. An "If" statement does a simple comparison, and you chose that correctly. All you need to do is fix your "If" statement and it should run as you expect it to.

            EXAMPLE:

            If [Database::Date1 = Database::Date2]

                Perform Script ["(Execute) Script 1"]

            Else

            Perform Script ["(Execute) Script 2"]

            End If

            Halt Script

            • 3. Re: Script Problem - Anyone can help?
              philmodjunk

              While I agree the script should be simplified, the original version still should have run script 1 only when the dates are equal and script 2 only when they are not.

              You may need to examine the data and field types for discrepancies. Are both date 1 and date 2 fields defined as fields of type date? (Or calculation fields that return date as their data types?)

              • 4. Re: Script Problem - Anyone can help?
                rjlevesque

                @Phil, so what if he made one script file, and put both in there...follow me and let me know if my thinking is correct please...

                So one script file, both have an Exit command at the end...so

                I agree with what you said, but I think it's not neccessarily script 1 firing, but simply one or the other...the results I think are leading him to believe only script 1 is firing, when in truth only ONE SCRIPT is firing. I could be wrong...but I believe both scripts are firing, just one or the either independantly, not either one based on a comparison...since it is not reading a true If/else statement.

                Wow, that was a lot more confusing to explain than it is to understand. LOL Please let me know if I lost anyone...

                RJ

                • 5. Re: Script Problem - Anyone can help?
                  philmodjunk

                  I don't follow what you are saying exactly.

                  I read his example as a single main script.

                  If so, the results of the orginal script and the simplified version should be the same. (If the fields have equal values the first script is performed. If they do not, the second is performed.) By using Else, you should get exactly the same result--only one of the two fire and he is reporting that script 1 is being performed even when the date values are different.

                  If so, there's another issue as yet undiscovered that is keeping the expression inside the If step(s) from correctly evaluating.

                  @Dummy Rabbit,

                  It would help to see the exact script, not an outline of it as there could be a key detail missing here.

                  To post a script to the forum:

                  1. You can upload a screen shot of your script by clicking the edit link to your original message and uploading it there
                  2. You can upload a screen shot to a file share site and post the download link to a new response you post here.
                  3. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF.
                  4. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
                  5. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional look to your script.
                  • 6. Re: Script Problem - Anyone can help?
                    rjlevesque

                    Even with an Exit script command at the end of each "IF" statement? That's what I was looking at...I figured the first EXIT Script would shut it down and prevent it from even firing off the second IF in that script file.

                    Did that make more sense? Or am I confusing everyone. LOL

                    I really have no idea, I have never constructed an IF statement in that manner of course so not sure...

                    • 7. Re: Script Problem - Anyone can help?
                      philmodjunk

                      The If with else does the same thing. With either script, only one of the two scripts can be performed. They just use different steps to accomplish the same result.

                      You have a point though if the user was expecting both scripts to be performed--which is not how I read the original post.