1 2 3 Previous Next 41 Replies Latest reply on Jan 28, 2017 5:56 PM by JackRodges

    Set Variable Question


      GOfmp WP Logo.png


      The problem is to bypass the need to manually do a Set Variable $$Name to value. Since I would need hundreds of variables, naming can be a problem.


      So I have an attached file that has two fields. One for the declared $$Variable and one for the value.


      I need a script, calculated field or custom value or maybe Java(?) to create these variables.


      Any ideas?


      Attached is a sample file and you can return it attached to your message for others to see.



        • 1. Re: Set Variable Question
          Johan Hedman

          You can use a Custom Function to great Variables, but you a referring to have a lot of Variable and that is not recommended. Very hard to keep track of all Variables. Of what reason do you need so many Variables?

          • 2. Re: Set Variable Question

            Any suggestion on what that custom function would be? I've tried Let and Evaluate but not found the key. Use the filed and add the custom function.


            If it works, give yourself a raise and an extra week vacation.. 

            • 4. Re: Set Variable Question

              Your offer is obviously of no value.

              Why do you think you need to do this?

              • 5. Re: Set Variable Question

                It was a joke... 


                I will be creating an unknown number of variables to be used in buttons, etc. and these will have values that change. I could and have hard code the hundred or so variables and run that script but I want to set the values using the two fields in loop running thorugh the hundred or so records.


                I have done this quite easily in other db applications since I can write a one line function similar to



                  Set variable name in field A to value in field B.

                end loop


                I learned how to do this within 2 days of learning my first db, DBase in windows in 1984.


                I have tried many ideas with FIleMaker but no luck. Stuck with that Set Var thing instead which means hundreds of lines of set variable.

                • 6. Re: Set Variable Question

                  I would suggest that, instead of using "hundreds" of separate variables, that you instead use either an array of values ( $$varName[x] ) or use a return-delimited list and extract the specific value needed via GetValue ( ).


                  But again, it begs the question Bruce asked: For what purpose? "Hundreds" of buttons would result in an unworkable user interface, so what are these hundreds of variables being used for? There's probably another way to accomplish this goal.

                  • 7. Re: Set Variable Question

                    gofmp wrote:

                    [...] or maybe Java(?) [...].

                    A new classic from the master.

                    • 8. Re: Set Variable Question

                      Not quite sure why you would want to do it, but anyway, please find attached file which has a looping script which does just that....


                      You might also want to take a look at this article: Dynamically Naming A Variable | The Support Group

                      • 9. Re: Set Variable Question

                        It may be simple, make Let() formula and Evaluate() it,

                        Evaluate ( "Let($$" & table::varname & ";" & table::value & ")" )

                        if value is text you need Quote(table::value)

                        • 10. Re: Set Variable Question

                          Amplifying Mike's point here, but also adding that in Java or other real programming languages, you NEVER create that many variables in a class or other object. NEVER. NEVER. NEVER.


                          If you were to run a Java source code analyzer like PMD or FindBugs on such Java code (free, of course), they would tell you to reduce complexity! Also, such source code with that many variables would never survive a peer code review!


                          Having so many variables "screams"...redesign.


                          HOPE THIS HELPS.

                          • 11. Re: Set Variable Question

                            Just loop with the Let function which allows you to set variables dynamically as was mentioned earlier.  We use this technique to allow for localization (multiple languages) in our solutions.  For example, our "Kosmas" solution loads around 5000 phrases, all stored as global variables.  All labels, headers, descriptions, tooltips...everything we possibly can is named with a global variable.  Switching from English to Russian and then to Korean is easy.  This even allows users to adjust the name of anything, solution wide, without having layout access.

                            • 12. Re: Set Variable Question

                              fmpdude wrote:

                              Amplifying Mike's point here, but also adding that in Java or other real programming languages, you NEVER create that many variables in a class or other object. NEVER. NEVER. NEVER..

                              Just that a "variable" in Java is not the same as a variable in FM.


                              While a table with 300 fields is usually* a red flag, creating 300 variables ad hoc might be just the solution to a pressing problem, or be used for interface purposes.


                              So one should never say never (especially not in Caps Lock )


                              *Unless you need to manage an entity that *does* have 300 attributes.

                              • 13. Re: Set Variable Question

                                A variable is a variable, sorry.


                                I can't think of a single entity that would need 300 variables, can you? Or, to wit, an entity that couldn't then be conceptually simplified.


                                The concept of "Abstraction" seems to be lost here.


                                Thanks for your reply.

                                • 14. Re: Set Variable Question

                                  I've considered many ideas including the repeating variable.


                                  The idea is to create labels for buttons since the $$global can be used to name a button and for labeling fields.


                                  I am using this for instant language changes. I only submitted the two fields but there would be a field for language name. Search for the language then loop through the records and all my buttonds and field labels would change to the user's choice of language.


                                  I've done it by manually naming the variable and using a list and here's a sample line:


                                  set var $loop to $loop +1

                                  set var $$Done to getvalue $$list  line $loop


                                  Now add that line manually every time you need a new variable and it gets to be a burden. Hence my request.


                                  I name my Done button $$Done and can change it with a language selection.

                                  1 2 3 Previous Next