4 Replies Latest reply on Sep 8, 2010 5:59 AM by Emily62

    debugging script in filemaker pro

    Emily62

      Title

      debugging script in filemaker pro

      Post

      I am helping a friend (who runs a small preschool) migrate from filemaker 3 to filemaker 11.  Almost everything works at this point, except for one script (which I did not create).  Since she only has filemaker pro (not advanced) I can't use the debugger. Any advice would be appreciated!

      Thanks, in advance,

      Emily

      ************

      The specific problem is this:

      The file contains three variables:  "name", "day number" and "total days".  Day number has 31 repetations (for each day in the month).  My friend enters a "1" in each day that a person is present and then the file computes the total days/month that each person attends.

      At the end of the month, a script ("clear") is supposed to initialize the file so that each field in "day number" contains a "-" for the start of the next month.  At this point, the script only initializes the "name" holding the cursor, not the complete file. 

      **********

      The script is: (I'm typing this in, by hand, because I can't figure out how to cut/paste from the script, so please excuse typos)

      Show All Records

      Enter Browse Mode []

      Go to Field [Attendance::Day Number]

      Clear [Select]

      Go to Field []

      Replace Field Contents [Current Contents]

      Go to Field [Attendance::Day Number[2]]

      Clear [Select]

      Go to Field []

      Replace Field Contents [Current Contents]

      (The script repeats this for Day Number [3] through [31].  For days [4] and later, "No dialog;" appears before "Current Contents")

      The script ends with

      Go to Field [Attendance::Day Number]

        • 1. Re: debugging script in filemaker pro
          philmodjunk

          What layout is current when you run this script and is all repetitions of Day Number visible on this layout?

          Clear only clears a field if that field is present on the current layout.

          Set Field [Attendance::Day Number ; ""] can clear a field without the field being physically present on the current layout nor do you have to use go to field to place the cursor in the field, though the current layout needs to refer to Attendance in the Show Records from box in Layout Setup...

          With Replace Field Contents, you can use the calculation option to clear the fields without the Clear Select and go to field steps. You can even put this script in a loop with a variable that tracks the current repetition reference instead of 31 Replace field contents steps.

          Note that no part of your script is putting a "-" in the field repetitions, it's simply deleting the current contents to make them empty. Also note that Replace Field Contents can fail to work correctly if you are sharing the file over a network and there is any chance at all that another user might be editing one of these records at the time your script attempts to use Replace Field Contents. The other user will "lock" the record and you'll get an error message telling you that one of the records was not updated, but not which one it was. Thus, Replace Field Contents should not be used unless you are completely certain that no other user can edit on of the records being updated by it.

          Final hints:

          1. If you can't use Filemaker Advanced, (it's debugger is well worth the extra $$), you can insert pause/resume script steps into strategic points so you can examine fields on your current layout, then you can continue the script to the next pause point and check again. You can also use Show Custom Dialog to both pause the script and display the values of fields and/or variables.
          2. If you want to copy and paste a script, you can copy script text from a PDF of your script using the PDF reader's text tool. With advanced you can also copy and paste script text from the Database Design Report.
          • 2. Re: debugging script in filemaker pro
            Emily62

            Thank you very much for this helpful response!  I have figured out how to use Replace Field Contents, rather than Field Select.  Can you give me any pointers in putting in a loop?  Specifically, how do I define the variable to track the iteration of the Day Number variable (which ranges from 1-31)? 

            Thanks again!

            Emily

            • 3. Re: debugging script in filemaker pro
              philmodjunk

              I'd probably use a table of related records for this instead of a repeating field, but since you asked for the looping script with the repeating field...

              Set Variable [$I ; value: 1 ]
              Loop
                Replace Field Contents [No dialog ; Attendance::DayNumber [$I ] ; ""]
                Set Variable [$I ; Value: $I + 1 ]
                Exit Loop If [ $I > 32 ]
              End Loop

              • 4. Re: debugging script in filemaker pro
                Emily62

                This worked--Thank you so much! 

                I appreciate your point about better ways to do this....maybe if I ever have some free time, I'll rewrite the whole thing.  But until then....

                Emily