5 Replies Latest reply on Oct 23, 2011 8:26 PM by projay

    Set Variable capture

    projay

      Title

      Set Variable capture

      Post

      Do you have to goto a particular layout to capture a variable.  I am in one layout but would like to capture a field value in another layout...hope this makes sense.

      -Jay.

        • 1. Re: Set Variable capture
          ninja

           Howdy,

          It doesn't matter what layout you are on, but what TABLE OCCURENCE (TO) that layout is based upon.  Setting a variable or a field is based on your current perspective.

          If you are on a layout based on a table that includes the field, go ahead and set the variable.

          If you are on a layout based on a different table, and the current TO is related to the table (any TO of it) you want, you will get the field value from the first related record as defined by the relationship between your current TO and the target table's TO.

          If you are on a TO that is not related to the target field's TO, the variable will stay blank (and FMP will think to itself "I don't know what you're talking about")

          Perspective is based on TO's.
          The layout you are currently on defines the TO from which you view the database.

          • 2. Re: Set Variable capture
            philmodjunk

            There are variables and there are fields.

            Variables are not specific to any one table and thus not specific to any one layout. Once you've assigned a value to a variable, you can access that variable's value from any layout, providing the variable still exists.

            If you use set variable or a Let function to create a variable with $$ at the start, you have created a global variable and it will exist for as long as you have the database open. One script can create the variable and assign it a value. Other scripts can access and modify it--and from any layout.

            If you use a single $, you have created a local script variable and the variable will exist and be accessible only from other steps in the same script. Once the script terminates, the variable is gone.

            With the let function, it's also possible to not use any $. In that case, the variable is viable only with the enclosing parenthesis of the let function that created it.

            • 3. Re: Set Variable capture
              projay

              Thanks for the fast replies...So basically I can set a script to run global variables when I start filemaker and the values should be their for later use as needed.   Am I on the right track?

              -Jay.

              • 4. Re: Set Variable capture
                LaRetta_1

                If you set global variables ($$) then they will be there for the duration of the file and be available from anywhere.  It is common for a Developer to, upon file start, go to Preferences layout (one-record table), write field values to global variables and then go about the work.

                • 5. Re: Set Variable capture
                  projay

                   Hey everyone...once again my questions were answered...thanks for your fast response.

                  -Jay.