4 Replies Latest reply on Apr 23, 2010 4:15 PM by Michael

    Data Sharing

    formerpigeek

      We have a problem about how to share the data between two PDI files.

       

      Every PDI file creates a project in the VBA. The data has to be shared between these two projects of VBA or pdi files.

       

      Can anyone give us pointer for achieveing this functionality.

        • Re: Data Sharing

          If your 2 displays are 2 items of a same workbook (PIW) file, then you can insert a "module" into your VBA project (right-click on ThisDisplay > Insert > Module), declare global variables in there and use them to hold the data you need to share.

           

          If your 2 files are 2 different PDI files, you might want to use a file as the intermediate - you can look into creating some plain text file (.ini or .config type file) in, say, the user's "Application Data" folder. You could even use the Windows Registry for that matter, but this tends to become less popular.

           

          Another option is to refactor what you are doing into a .NET Add-in. It may not make sense depending on what you are doing, but that is another option... the more we go, the more you will see things being developed as add-ins rather than display-specific bits of VBA code. It provides several advantages (some disavadvantages too, admiteddly) and greatly facilitates persiting data for use by various displays (since it is an application-level thing rather than PIW- or PDI-specific). See this webinar for more information.

           

          Hope this helps!

            • Re: Data Sharing

              Steve Pilon

              If your 2 files are 2 different PDI files, you might want to use a file as the intermediate - you can look into creating some plain text file (.ini or .config type file) in, say, the user's "Application Data" folder. You could even use the Windows Registry for that matter, but this tends to become less popular.

               

               

              Talking along these lines, you could add a reference to a PDI that contains common data/code.

               

               

                • Re: Data Sharing
                  formerpigeek

                  Hi Rhys,

                   

                  We would like to achieve data sharing under the following scenario,

                   

                  Say we have Display1 and Display2, In Display1 we have a button on click of which we need to Open Display2 and also pass a string information to Display2 from Display1 button so that Display2 will know which button of Display1 has been pressed.

                   

                  Thanks and Regards

                   

                  Kavita

                    • Re: Data Sharing
                      Michael

                      The idea is to have another (3rd) display (say main.pdi) containing most of the source code and acting as the central control instance. Pushing btn on display1 assigns a value to a global variable in the main.pdi and you can read the content in display2.

                       

                      This approach has a lot of advantages. Most of the source code is in one display and is not repeated in each display. It is easier to develop (VBA not .NET) and to distribute (no registry handling) then an addin.

                       

                      But keep in mind that such "applications" tend to grow, so always consider creating an addin.

                       

                       

                       

                      Michael