1 2 Previous Next 27 Replies Latest reply on Jul 11, 2017 12:54 AM by Fred(CH)

    Beware with FMP 16 : Windows based variables BROKEN

    Fred(CH)

      With prior versions (since 11 at least), it was possible to index a global variable upon a window (a window based variable). The trick used was to pass in the repetition of the variable the expression Code ( Get ( WindowName ) ). You get a tremendous number with, lets say, maybe 30 digit, but it worked like a charm as a repetition number. The new version broke this technique since it seems the repetition of a variable only retain the 17 last digits.

       

      View in Report an Issue space

        • 1. Re: Beware with FMP 16 : Windows based variables BROKEN
          LSNOVER

          I've never heard of this technique.  Could you elaborate?

          • 2. Re: Beware with FMP 16 : Windows based variables BROKEN
            wimdecorte

            It's called the 'named buckets' so you can google on that.  It basically works off the fact that variables can have repetitions.  And those don't need to be sequential.

             

            So if you loop through data say and you want to store an invoice total for me and one for yourself you do

             

            Set Variable[ $invoice_total [ code( "wim" ) ] = 100 )

            and when you get to your record you do:

            Set Variable[ $invoice_total [ code( "lee" ) ] = 400 )

             

            And you can then call on that variable by calling it's named bucket just as easily without having to remember in what rep you stored it.

             

            I used that a lot in my 2014 devcon preso, you can find the demo file here:

            Using ExecuteSQL() calls in FileMaker - Soliant Consulting

            3 of 3 people found this helpful
            • 3. Re: Beware with FMP 16 : Windows based variables BROKEN
              wimdecorte

              Fred(CH): is this failure based on the length of the string that is converted to Code()?

              • 4. Re: Beware with FMP 16 : Windows based variables BROKEN
                Fred(CH)

                Well maybe better not .

                 

                I think it was an idea of DavidJondreau, or at least, he gently gave me the trick.

                 

                It was useful to manage a variable for each windows open, using the name of the window as the repetition number.

                 

                An example :

                 

                I have a OnRecordLoad Trigger that set a such global variable to store the Record ID of the active record and then, i can then use the same variable on a conditional formatting to highlight the line (put the text in blank)  :

                Capture d’écran 2017-05-10 à 12.52.25.png

                 

                However, when you are opening multiple windows, you have to store the Record ID for each of them. Here is the point of this technique.

                 

                Afterwards, you can delete the variable with a OnWindowsClose Trigger the same way.

                LSNOVER a écrit:

                 

                I've never heard of this technique. Could you elaborate?

                • 5. Re: Beware with FMP 16 : Windows based variables BROKEN
                  Fred(CH)

                  wimdecorte : Yes As far i can see. It is the Set Variable step that is the culprit because the generated variable have an incorrect repetition number in the Data Visualizer, that is truncated to 17 digit.

                  • 6. Re: Beware with FMP 16 : Windows based variables BROKEN
                    alecgregory

                    Yes, it's definitely the set variable step.

                     

                    You can work around this by using a let function to set the variable:

                     

                    Let (

                      $$LONG_REPETITION[9999999999999999999999999999999999999999999999999] = 10;

                      1

                    )

                     

                    The above works where using the set variable script step truncates the repetition number to 17 digits as you observed.

                    5 of 5 people found this helpful
                    • 7. Re: Beware with FMP 16 : Windows based variables BROKEN
                      alecgregory

                      I guess with FM16 we could also use a JSON object to get the same functionality:

                       

                      JSONSetElement (

                           $$BUCKET_OBJECT;

                           Get ( WindowName );

                           "Some Value";

                           JSONString

                      )

                       

                      JSONGetElement (

                           $$BUCKET_OBJECT;

                           Get ( WindowName )

                      )

                      4 of 4 people found this helpful
                      • 8. Re: Beware with FMP 16 : Windows based variables BROKEN
                        TomHays

                        The string of digits returned from Code(Get(WindowName)) can easily be way longer than 30 digits.  For strings longer than a few characters, the number of digits is at least 4 times the length of the string.

                         

                        Length( Code("Member: John Smith") ) is 88 digits.

                         

                        What you need is a hash of the string that yields an effectively unique number within the range usable by repetitions.

                         

                        If your window names are already unique in the last part (e.g  "My Database", "My Database - 1", "My Database - 2") then a simple Right(Code("Member: John Smith"); 17) will give you something short enough and sufficiently unique.

                         

                        If your window names are arbitrary (e.g. "Member: John Smith" vs "Member: John P. Smith") then you need to apply a more careful hash.

                         

                        It could be that using

                        Mod( Code(Get(WindowName)) ; 2^56)

                        will work.

                         

                        If that isn't unique enough you may need to do something with a custom function (e.g. ChecksumAdler32 ) or maybe something that leverages the new CryptDigest or CryptAuthCode functions in FM16.

                         

                        -Tom

                        1 of 1 people found this helpful
                        • 9. Re: Beware with FMP 16 : Windows based variables BROKEN
                          TomHays

                          TomHays wrote:

                           

                          If your window names are already unique in the last part (e.g "My Database", "My Database - 1", "My Database - 2") then a simple Right(Code("Member: John Smith"); 17) will give you something short enough and sufficiently unique.

                           

                          On closer inspection of the results of Code(), the expression should be

                           

                          Left(Code("Member: John Smith); 17)

                           

                          instead of Right().

                          The digits returned by Code() are apparently generated right to left.

                          Code("a") = "97"

                          Code("b") = "98"

                          Code("ab") = "9800097"

                           

                          -Tom

                          4 of 4 people found this helpful
                          • 10. Re: Beware with FMP 16 : Windows based variables BROKEN
                            LSNOVER

                            Well, I've been doing FM for 18 Years, and I use repeating fields all the time.   I thought I had all the tricks down, but it just goes to show there's ALWAYS something new to learn.   This is very interesting.

                            • 11. Re: Beware with FMP 16 : Windows based variables BROKEN
                              PeterDoern

                              If your system is fully-scripted, i.e. manages window creation and naming, you can include Byte Order Marks in your window titles to track them. Byte Order Mark = Char ( 65279 ), and is a "zero-width, non-breaking space".

                               

                              For example, when your system sets the title of the first window, it would be "Window Title" & Char ( 65279 ). Window 2 would be "Window 2 Title" & Char ( 65279 ) & Char ( 65279 ). And so on, incrementing the number of Byte Order Marks in the window titles as you create windows.

                               

                              Obviously you'd want to use a combination of a custom function and global variables to easily add as many  Byte Order Marks to the title as you wish and to track the next logical window number. Another custom function would be able to determine the "repetition" of your window variable by counting the number of Byte Order Marks in its title.

                               

                              I hope this makes sense.

                               

                              Peter

                              2 of 2 people found this helpful
                              • 12. Re: Beware with FMP 16 : Windows based variables BROKEN
                                jbante

                                The cryptographic hashes are overkill for this application. Mod ( Code ( Get ( WindowName ) ) ; someLargeNumber ) is probably fine. If a more rigorous hash function turns out to be necessary, start with MD5, which is faster than the other hash algorithms available, truncate however many characters of that you want, and convert it from hex to decimal. (MD5 isn't a cryptographic hash, but it doesn't have to be for this.) That may be faster than the Adler-32 custom function.

                                3 of 3 people found this helpful
                                • 13. Re: Beware with FMP 16 : Windows based variables BROKEN
                                  PeterDoern

                                  Or, for that matter, if you don't require a Windows menu that will let users navigate to other windows, or if you use custom menus to manage this, you can use the following in the window name calculation whenever you create a new window (via script):

                                   

                                  Let ( [

                                   

                                       $$WINDOW.COUNT = $$WINDOW.COUNT + 1

                                   

                                  ] ;

                                   

                                       "Window Title¶" & $$WINDOW.COUNT

                                   

                                  )

                                   

                                  Then you can extract the "Window ID" with GetValue ( Get ( WindowName ) ; 2 )

                                  1 of 1 people found this helpful
                                  • 14. Re: Beware with FMP 16 : Windows based variables BROKEN
                                    rcates00

                                    I posted about this today on another forum. Strange thing is I count 18 digits not 17

                                     

                                    FM 16 Variable Repetition limitation change? - FileMaker Pro 16 Discussions - FMForums.com

                                    1 of 1 people found this helpful
                                    1 2 Previous Next