4 Replies Latest reply on Jan 14, 2011 9:34 PM by GaryPrater

    Meaning of SetVariable and "$$" and such...

    Stereoinitials

      Title

      Meaning of SetVariable and "$$" and such...

      Post

      Hi,...

       

      Can someone explain to me the meaning of setvariable, setfield and "$$" ?

       

      $$ as in for example Go to Layout [$$LayoutName] ?

       

      How is setvariable related to global fields?... What are exactly global fields good for?

       

      Many thanks. 

        • 1. Re: Meaning of SetVariable and "$$" and such...
          mrvodka
            

          Honestly the best way to understand these is to read up on them in the help, past forum threads, and books.

           

          However, here is some info to get you started.

           

          Script variables with a single $ is local to the script that is being executed. Double $$ are how global variables are declared. These global variables persist through the users' sessions and are local to the file. (there are techniques on passing value to other files but not the actual variable itself, just the value)

           

           

          Global fields are also session specific and are local to the file. In a hosted environment, they will mantain the value that it was set at the time that file started being served or if a server side script updates it. These global fields can be accessed with independance from relationships. ( in other words you dont need a relationship if its located in another table ).

           

           

          Global variables are not the same as Global Fields. I have noticed that many people get them confused. If you want to store what layout a user last went to, you can store it in either one of them. However, one is a field and one just sits in the system memory.

           

          Does that help at all?

          • 2. Re: Meaning of SetVariable and "$$" and such...
            mmccarty
              

            Set Variable creates a temporary variable to hold data for the use of a script.  There are two types of variables, local ($) and global ($$).  A local variable only exists in script in which it was defined.  A global variable holds the value throughout a users session and it can be used in multiple scripts.  Variables just temporarily hold values for your use without effecting your records.

             

            Set Field is data entry.  If in a script I say SetField[ CustomerName; "Larry"], the current record customer name which was Frank now becomes Larry.  The Set Field script step directly effects the data in your records.

             

            Global Fields are fields in your tables that contain the same value no matter what record you are in.  For example, say you have the table customers, with 500 records.  The name field in that table probably does not have global storage because all your customers have different names.  Say for some reason you store financial data about each customer in this table and you want a field for sales tax.  That field would probably be a global field because Sales Tax doesn't change from customer to customer it is always the same.  Also, global fields can be used in another table wither they are related or not.

            Note: Global fields and global variables are not the same! 

             

            For your example.  At some point in a session a script ran with the step Set Variable[$$LayoutName; Get(LayoutName)].  When that happened, FM created a global variable which is storing the name of whatever layout the user was in when that step was executed.  Either another script or the same script (because global) contains the step Go To Layout[$$LayoutName] which tells filemaker to go back to that layout.

             

            I hope this all made sense.  Let me know if you need more explanation or some examples.  I'm sure there are some good articles on these topics in the Knowledge Base.

            • 3. Re: Meaning of SetVariable and "$$" and such...
              Stereoinitials
                 Thanks guys for the useful info!
              • 4. Re: Meaning of SetVariable and "$$" and such...
                GaryPrater

                Thanks mmccarty i think im starting to undeerstand. I am trying to get away from copy paste. Pretty much i have a Volunteer Table which has a __Vol_ID that gets used for everything from signing up to tracking hours. THe other big one is Events table __Event_ID. im trying to understand how to pull those in instead of doing the messing copy paste.