6 Replies Latest reply on Jun 22, 2013 12:06 PM by StephenWonfor

    Is the VariableSpace accessible via a script?

    StephenWonfor

      Hi

       

      I rather suspect I know the answer to this, but perhaps the "big brains" have figured this out.

       

      Can, what I call "VariableSpace", be queried without knowledge of its contents? Can one extract a list of all the active variable without knowing what they are?

       

      Stephen

       

      “ Without requirements or design, programming is the art of adding bugs to an empty text file. ” - Louis Srygley

        • 1. Re: Is the VariableSpace accessible via a script?
          mikebeargie

          Stephen,

           

          If you've got Filemaker Pro Advanced, you can just open the data viewer. This will display all session based variables ($$var) and also execution/script variables ($var) when you are stepping through a script in the debugger.

           

          As for querying it, no, I'm not sure you can, but I am not terribly familiar with all the new metadata functions that seem to have popped out of ExecuteSQL(). You can check a variable to see if it's declared (IE length($thisVariable) > 0 )

           

          Best practice is to use comments at the beginning of your scripts to comment about what variables are being declared below.

           

          You could also build in your own tracking measure by keeping a session variable list.

          IE set variable $$declared = $$declared & ¶ & thisVariable

          and run your check against $$declared. This doubles your script steps every time you declare (or undeclare) a variable though.

          1 of 1 people found this helpful
          • 2. Re: Is the VariableSpace accessible via a script?
            StephenWonfor

            Mike

             

            My question was based on another thread (Dynamic Variables) and got me to wondering if I could bulk clear a whole suite of dynamically created variables without knowing what they were called.

            SetVariableSpace[("")] sort of thing.

             

            Stephen

             

            "Weeks of programming can save you hours of planning."   -- unknown

            • 3. Re: Is the VariableSpace accessible via a script?
              DrewTenenholz

              Stephen --

               

              I think Ernest Koe's set of custom functions for variables basically did that sort of thing.  If I recall correctly, you called a function to store a variable and its value, and that function both created the dynamic variable and added its name to a global variable, thus making it possible to know what variables had been defined (or had yet to be defined) and then retrieve, modify, or clear their values.

               

              -- Drew

              • 4. Re: Is the VariableSpace accessible via a script?
                mikebeargie

                With custom functions as well, you can add "collision detection", IE patterncount() on the list to make sure you're not declaring or removing dupe variables.

                 

                Drew, did you have a link to the proof group blog post on that?

                • 5. Re: Is the VariableSpace accessible via a script?
                  peterbouma

                  Stephen,

                   

                  This may not be what you're looking for, but  Goya's invaluable Base Elements analysis tool  can give you all variables used in your application.

                   

                  Peter

                  • 6. Re: Is the VariableSpace accessible via a script?
                    StephenWonfor

                    Peter

                     

                    I do use BE.  What I was hoping to be able to do was to "scrape" the variable space realtime.

                     

                    Stephen

                     

                    ---

                     

                    I wrote an ad for Apple Computer: "Macintosh - We might not get everything right, but at least we knew the century was going to end."  ~Douglas Adams