KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Method to Find the Structure Mode of Database
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: December 28, 2020

In some cases, it may be helpful to know if the opened database structure is in binary or project mode. For example, the developer can have their component execute different code based on whether the host structure is in binary or project mode.

The method below can be used to find the structure mode of the database. When the method is called from a component, the host database structure mode is returned. The method cannot be called in remote mode. It must be executed on the Server in a Client/Server environment.

//======================================================
//DESCRIPTION: Method finds whether the structure opened is a binary or project structure. Finds the structure of the host database if executed from a component. Method cannot be called in remote mode. Must be executed on the Server in Client/Server environment.
//OUTPUT:
//- $0 returns "Binary" in binary mode
//- $0 returns "Project" in project mode
//======================================================


C_OBJECT($structure_o)
C_TEXT($exten_t;$mode_t;$0)

If (Application type#4D Remote mode)
   $structure_o:=Path to object(Structure file(*))
   $exten_t:=$structure_o.extension
   Case of
   : ($exten_t=".4DB") | ($exten_t=".4DC")
   $mode_t:="Binary"
  
   : ($exten_t=".4DProject") | ($exten_t=".4DZ")
   $mode_t:="Project"
   End case
  
   $0:=$mode_t
End if