1 2 Previous Next 18 Replies Latest reply on Jun 18, 2017 8:30 PM by bigtom

    Set a $$Variable to a field?

    gofmp15

      Someone posted a fix to my attempt to put the contents of a field into a $$Variable using a script.

       

      Now I am curious as to how to avoid using a loop after finding a set of records and putting each into a $$Variable.

       

      The criteria:

      The table contains words that become variables: Desk becomes $$Desk

      The record has a field for the name of the language and the translated text.

       

      The current method is to use a loop to put the translation into the $$Variable

       

      Record:

      English: Desk

      Variable Name: $$Desk (calculated from english)

      Language: English (etc)

      Translation: Desk (etc)

       

      My idea or hope is to add another field that will

       

      If $$DefaultLange = Language

      set variable Variable Name to Translation

      end if

       

      There may be 12 or more records (one for each language) for a specific $$Variable and hopefully this calc would only work for the $$DefaultLanguage.

       

      OK, I'm going to try on my own but wait for suggestions...  Thanks.

        • 1. Re: Set a $$Variable to a field?
          bigtom

          Were you able to download the file I posted?

          • 2. Re: Set a $$Variable to a field?
            gofmp15

            As mentioned the file does not show up as an attachment. Maybe try a repost?

            • 3. Re: Set a $$Variable to a field?
              bigtom

              I trust the link should work for you and decided to move the conversation here from now.

              • 4. Re: Set a $$Variable to a field?
                bigtom

                If $$DefaultLange = Language

                set variable Variable Name to Translation

                end if

                 

                I usually do this part with an additional global field to check if the language selected is already the current language displayed.

                 

                If g_selector≠g_selected then Refresh Window. The demo file does not have this though.

                • 5. Re: Set a $$Variable to a field?
                  gofmp15

                  Well, you have succeeded in causing me several hours of contemplation, the possible redesign of my idea to work with yours and the heartbreaking realization that we all come to on ocassion that days, weeks, months of work are down the drain.. 

                   

                  Who discovered this?

                  Is this technique documented by FileMaker?

                  How long has this worked, years?

                  Will it break if FileMaker changes the way value lists work?

                   

                  Who would have guessed?

                  • 6. Re: Set a $$Variable to a field?
                    bigtom

                    gofmp15 wrote:

                     

                    Well, you have succeeded in causing me several hours of contemplation, the possible redesign of my idea to work with yours and the heartbreaking realization that we all come to on ocassion that days, weeks, months of work are down the drain..

                     

                    Who discovered this?

                    Is this technique documented by FileMaker?

                    How long has this worked, years?

                    Will it break if FileMaker changes the way value lists work?

                     

                    Who would have guessed?

                    I went through a similar process getting to this point. I would not say your work is down the drain. This is a stripped down demo. There is no filtering for variable names. I only added the Substitute to deal with a few hyphenated words in the random word list I used for the demo. An auto enter variable name is not a bad idea, but its not needed if you want to save data transfer.

                     

                    There are plenty of other cool things I have for localization.

                     

                    I am not sure of anyone else doing this exactly, but all the parts individually are known. There were a lot of "Wait... what if I did this?" in the process. The main drive for me on this was developing a fast label localization module that worked well on WAN and had good seamless layouts without flashes. The loop script on older iOS devices was too slow. Needless to say i use this in many other ways as well.

                     

                    This exact process is not documented by FM.

                     

                    It has been working for me since FM13.

                     

                    FM has not changed basic value lists since anytime I know and I am not sure they ever will. I only use the Language value list this way as it is in a separate table that allows for easier interaction with translation APIs using standard language abbreviations. Also less storage.

                     

                    I use this concept in a script just the same as it is a single set variable step and then a refresh. Tucking it away was just to give you something to think about. When used this way it evaluates before layout rendering and thus no need for a refresh on first layout load (which can take time). If you have a language select splash screen and then move to the solution layouts from there it keeps the UI more seamless.

                     

                    If you end up using this feel free to hook me up with a copy of the finished file.

                    • 7. Re: Set a $$Variable to a field?
                      bigtom

                      Using this in a set variable script step has been working since FM12.

                      • 8. Re: Set a $$Variable to a field?
                        gofmp15

                         

                         

                        You had me there for a while... Congratulations...

                         

                        Of course you don't need a scripted loop...you have a SQL thingy hidden in the label above the popup and disguised by having the label expanded so the eye icon doesn't show unless you really look for it...

                         

                        Since I have been traumatized by trying to debug databases designed by others that tried such tricks, I won't use this but I do like it. It's too easy to delete some innocuous object or overlook it (like I did when trying to mimic your method). I can just imagine how much pain would arise later when that little label is deleted...

                        • 9. Re: Set a $$Variable to a field?
                          philmodjunk

                          One one adds a "cute trick" to a layout, one should always, always document it in a manner very visible to other developers. I personally use two methods:

                           

                          1. Large, visible layout text off the right hand edge, or hidden via Hide Object When in Browse mode.
                          2. An attached "Developer notes" table that documents any unusual features for the layout and/or scripts associated with it.
                          • 10. Re: Set a $$Variable to a field?
                            bigtom

                            It's a small enough file that a look at the DDR gives it up quick enough. Hiding the calc was just a bit of fun on this one. I guess there is a "thank you" and a "sorry about that" in there. I most often use this in a script as I get more control.

                             

                            The main part is the calculation to skip any finds or loops. It is the quickest way I could find to build the Text for Evaluate ( ). I hope you see the value there.

                            • 11. Re: Set a $$Variable to a field?
                              gofmp15

                              No problem. It was a fun excercise and once again proves why I am so good. Almost as much fun as finding out how to get full access to an older file created by an owner who passed away and used his how scripted password to control things...

                               

                              If you can find a way to place your sql calc inside a calculated field to accomplish the same action...

                               

                              FileMaker's arcane method of evaluating variables, etc. with Let and evaluate make it difficult to accomplish, for me, what is easier in other dbs.

                              • 12. Re: Set a $$Variable to a field?
                                bigtom

                                I am glad you took it well enough. I did not think it would take you

                                long to figure out. I thought about adding some congratulations text in

                                there too I never hide things like that in production.

                                 

                                You can use the exact calculation in a script or field and get the same

                                functionality. For my uses a script is often better for me, but either

                                way works.

                                • 13. Re: Set a $$Variable to a field?
                                  gofmp15

                                  I'll try it in a field. How about a caluclated global?

                                  • 14. Re: Set a $$Variable to a field?
                                    bigtom

                                    Works in a a calc global as well.

                                    1 2 Previous Next