3 Replies Latest reply on Dec 30, 2011 10:02 AM by philmodjunk

    Setting the context for Get ( FoundCount)



      Setting the context for Get ( FoundCount)


       This is probably a newbie issue but I"m stuck.  I'm using the Get ( FoundCount) function in a script with the need to perform an numeric calculation.  However, the calculation field indicates that the result must be Text, which means I cannot perform the calculation.  The Function Reference for Get ( FoundCount) states "If you specify the context for the current calculation, this function will be evaluated baseed on that context..." 

      How do I specify the context on a non-field related function such as Get ( FoundCount)?


        • 1. Re: Setting the context for Get ( FoundCount)

          Is this inside a set variable script step?

          If so, you can ignore that "must be text" reference and it will successfully enter the current found count into your variable.

          In a script, context is determined by the layout that is current at the moment the script step executes. The layout refers to a table occurrence (a box in Manage | Database | relationships), and each table occurrence has it's own current record, found set and sort order that refers to its data source table. Thus, you must use specify a layout to establish the needed context for your script.

          In calculation fields, there's a context drop down at the top of the specify calculation that you use to establish context. This is separate from what layout might be current at the time you see the data returned by that calculation field--thus it can refer to a table occurrence in its calculation that is not even linked to the current layout's table occurrence and it will still display a value.

          • 2. Re: Setting the context for Get ( FoundCount)

             Yes I'm setting a variable based on the found count value so I can perform a subtractive calculation in a loop within a script.  Your comments make sense because I would think the found count value would strickly be a numeric value.  I couldn't get the calculation to work and I thought the problem was that I was attempting to add text values.  Therefore I must be doing something else wrong.  I appreciate the prompt response and the encouragement to relook at my code.

            BTY I sould have mentioned I"m using FMPro Avanced v.9.



            • 3. Re: Setting the context for Get ( FoundCount)

              BTY I sould have mentioned I"m using FMPro Avanced v.9.

              Always let folks know if you are not using the latest release of FileMaker or we may suggest something incompatible to your version. That's not the case here, but next time might be different...

              Feel free to post your script or the calculation you are using if you want a second pair of eyes on that script to help you figure out why it isn't working.

              To post a script to the forum:

              1. You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
              2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
              3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
              4. 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 and easier to read format. (Use the HTML option on the database tab panel and paste the text into the forum's HTML editor.)