KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Components: Test if you are running as a Matrix database
PRODUCT: 4D | VERSION: 11 | PLATFORM: Mac & Win
Published On: May 14, 2009

It can be important to know if a database is running as a Matrix database or as a Component Database. Here is an easy snippet of code to put in your Database On Startup method to launch the component; in this case, 4D Pop. It would be easy to include any other code or flags to the code, and use it for more than the 4D Pop component.

`This line checks if database is currently a Matrix or Component
If ((Structure file=Structure file(*)) & Not(Is compiled mode))
    ARRAY TEXT($Components_aT;0)
    COMPONENT LIST($Components_aT)
    If (Find in array($Components_aT;"4DPop")>0)
        EXECUTE METHOD("4DPop_Palette")
    End if

  `Add other code here
End if

Commented by Thomas Fitch on May 27, 2009 at 2:59 PM
I use this when I have components that create tables in the host database. If they are running as a Matrix database then I do not run the code, but if they are running as a Component they check to see if the table exists, and if not they create it and populate it with data necessary for the component.