1 2 3 4 Previous Next 47 Replies Latest reply on Apr 29, 2015 12:53 PM by jbante

    Setting a variable or calculation field that is window specific?

    jgalt

      Is it possible to set a variable or a calculation field that will show the user's current tab selection, but only for that instance of the window?

       

      For example, if the user opens multiple copies of the same window I need it to show the current tab selection for that window instance without influencing the other windows.

       

      The solution is running on a sever with mutiple users. The layout is a session layout and only contains a single record.

       

      I have attached an example of what I am trying to do and here is a screen capture:

       

      g1yDuz

        • 1. Re: Setting a variable or calculation field that is window specific?
          wimdecorte

          Check out this custom function:

           

          FileMaker Custom Function:FrontTabs( layoutObjects; parent )

           

          and in general, the GetLayoutObjectAttribute function: GetLayoutObjectAttribute

          • 2. Re: Setting a variable or calculation field that is window specific?
            user19752

            How about using one variable per each window?

            $$var[Code(Get(WindowName))]

            • 3. Re: Setting a variable or calculation field that is window specific?
              jgalt

              Wim, thanks for the link. I have installed that custom function but I don't quite understand his input example or how to implement it to my solution.

               

              FrontTabs ( layoutObjects ;  parent )

               

              example input?

              let( objectList = LayoutObjectNames ( Get( FileName) ; Get ( LayoutName ) ) ;

              frontTabs ( objectList ; "" ))

              • 4. Re: Setting a variable or calculation field that is window specific?
                jgalt

                user19752 wrote:

                 

                How about using one variable per each window?

                $$var[Code(Get(WindowName))]

                Sorry, I don't understand. What do I put on my layout to display this?

                • 5. Re: Setting a variable or calculation field that is window specific?
                  jgalt

                  Wim, I was able to get the custom function to work. I think there was a typo on the input example on the download page but the input example in the comments made more sense...and worked.

                   

                  Unfortunately the behavior using the custom function is the same as my example file. When the user refreshes the window it inserts the value from whichever window had the last tab change.

                  • 6. Re: Setting a variable or calculation field that is window specific?
                    wimdecorte

                    It was not clear to me that this was the issue you were facing.  In that case, user19752's input is the way go: make sure through scripted interaction or event handling you set the


                    $$var[Code(Get(WindowName))]


                    to the frontmost tab of the current window.


                    The Code( Get(WindowName) ) translates the window name into a unique number used in the repetition of the $$var variable.  If you use $$var as a merge variable on the layout, then as each layout draws / redraws it will pick from its own repetition of the variable.

                    • 7. Re: Setting a variable or calculation field that is window specific?
                      jgalt

                      wimdecorte wrote:

                       

                      It was not clear to me that this was the issue you were facing.  In that case, user19752's input is the way go: make sure through scripted interaction or event handling you set the


                      $$var[Code(Get(WindowName))]


                      to the frontmost tab of the current window.


                      The Code( Get(WindowName) ) translates the window name into a unique number used in the repetition of the $$var variable.  If you use $$var as a merge variable on the layout, then as each layout draws / redraws it will pick from its own repetition of the variable.

                       

                      This capability sounds very interesting. I did not know that you could do that with a merge variable.

                       

                      It's still not clear to me where I need to insert the $$var[Code(Get(WindowName))]


                      Currently I have variable: $$CurrentTab


                      ...and I am setting it with this calculation: GetValue ( Get ( TriggerTargetPanel ) ; 2 )


                      Where do I insert [Code(Get(WindowName))]?

                      • 8. Re: Setting a variable or calculation field that is window specific?
                        wimdecorte

                         

                        It's still not clear to me where I need to insert the $$var[Code(Get(WindowName))]


                        Currently I have variable: $$CurrentTab


                        ...and I am setting it with this calculation: GetValue ( Get ( TriggerTargetPanel ) ; 2 )


                        Where do I insert [Code(Get(WindowName))]?

                         

                        The place where you set $$currenttab is where you specify the repitiion number.  It's the bottom section of the Set Variable script step.

                        If you are using a calculation to set the variable then you have to use the square brackets syntax to set it:

                         

                        let(

                         

                        $$currentTab[ some_rep ] = "something"

                         

                        )

                        • 9. Re: Setting a variable or calculation field that is window specific?
                          siplus

                          It's not yet finished but you might find some ideas in the attached elaboration.

                          • 10. Re: Setting a variable or calculation field that is window specific?
                            wimdecorte

                            siplus wrote:

                             

                            It's not yet finished but you might find some ideas in the attached elaboration.

                             

                            Can I ask you a favor?  Could you summarize your ideas in the post?

                             

                            Otherwise I have to download the file and then evaluate if it has things in it that I like or not.

                            • 11. Re: Setting a variable or calculation field that is window specific?
                              jbante

                              You can't display variable repetitions as a merge variable on a layout, much less use a calculation for the repetition number. So you're stuck using the same repetition of the same variable for each window. No problem! Use the "Hide Object When" calculation on the object to set the variable. When the layout draws in one window, it will run the Hide Object When calculation before rendering the label. When another window refreshes, the first window is unaffected by the change to the same variable because it hasn't re-drawn yet. (One bonus of this is that you can use a local $variable instead of a global $$variable.)

                               

                              We used to be able to do this kind of thing with conditional formatting, but conditional formatting calculations are very sensitive to the stacking order of objects on the layout. Using "Hide Object When" calculations now is much more reliable, and the calculation that sets a merge variable can be attached to the same object that displays the variable.

                              • 12. Re: Setting a variable or calculation field that is window specific?
                                jgalt

                                wimdecorte wrote:

                                 

                                The Code( Get(WindowName) ) translates the window name into a unique number used in the repetition of the $$var variable.  If you use $$var as a merge variable on the layout, then as each layout draws / redraws it will pick from its own repetition of the variable.

                                 

                                Wim, I understand that "Code(Get(WindowName)" translates the window into a unique number. I have tested this using a merge variable and I see the unique result in each new window that I open. What has me stumped is the part where you say that this can be used to pick from it's own repetition of the variable. Can you please explain what you mean by this?

                                 

                                Every attempt that I have made to get this to work has failed. Any window that I refresh replaces the value of the merge variable with the last value that was set by the script...regardless of which window that was in.

                                 

                                In my example file I have a panel with three tabs with named objects for each:

                                 

                                Tab1 = Apples

                                Tab2 = Oranges

                                Tab3 = Pears

                                 

                                These values are being passed to the global variable "$$CurrentTab as a script parameter using an OnPanelSwitch trigger.

                                Get(ActiveLayoutObjectName)

                                 

                                The script has two steps:

                                Set Variable [$$CurrentTab; Value:GetValue ( Get ( TriggerTargetPanel ) ; 2 )]

                                Refresh Object

                                 

                                I am grabbing the second value that is being passed by the script parameter.

                                 

                                Can you please how I can use "Code(Get(WindowName)" method that you described to create a global merge variable that is not influenced by copies of the same layout being manipulate in other windows? Again, the problem occurs when one of the windows has been refreshed. It simply updates the global variable to the last value that was set by the script.

                                • 13. Re: Setting a variable or calculation field that is window specific?
                                  jgalt

                                  siplus wrote:

                                   

                                  It's not yet finished but you might find some ideas in the attached elaboration.

                                  Thanks very much siplus for taking the time to create that example. Very interesting. I am testing it now.

                                  • 14. Re: Setting a variable or calculation field that is window specific?
                                    user19752

                                    I forgot to wite my idea need window names are unique, it can be not unique.

                                     

                                    To embed layout as merge variable, change it to like

                                    Evaluate ( "Let($$var_" & Get(WindowName) & "=" & some calculation for getting info to show ; "" )

                                    1 2 3 4 Previous Next