KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using Design Object Access commands from compiled component
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: March 9, 2012

The new Design Object Access commands in 4D v13 are used to access the content of methods, only in interpreted mode. However, there is a specific scenario where the commands can be executed from a compiled database. The specific scenario is compiled components.

This is possible because 1) the Design Object Access commands contain options for accessing methods of the host database and 2) of course, components can be compiled.

Here is one possible scenario where this functionality would come in handy:

Say a compiled component is being deployed to customers. The component has its own startup method (ex. Comp_MyStartup) with some initialization code that must run when the host database starts up. Using the Design Object Access commands, a check can be added to any of the other component methods which can check to see if the component's startup method is in fact installed in the host database's On Startup method.

Here is some sample code that will be capable of performing this check:

C_TEXT($startupCode_t)
C_LONGINT
($pos_l)

If (Not(Is compiled mode(*))) //if host database is running interpreted mode

    //check if host DB calls the component's startup method in On Startup
  METHOD GET CODE("[databaseMethod]/onStartup";$startupCode_t;*)
  $pos_l:=Position("Comp_Startup";$startupCode_t)

  If ($pos_l<1) //method not installed

      //add method
    $startupCode_t:=$startupCode_t+Char(13)+"Comp_Startup"
    METHOD SET CODE("[databaseMethod]/onStartup";$startupCode_t;*)

  End if

End if