KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: A utility method to determine current UNICODE mode and option to switch
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac
Published On: December 1, 2011

There are times when it may become necessary necessary to confirm what mode a database is running in, UNICODE or Compatibility, and change the mode for testing purposes. To determine what mode a database is currently in the command Get database parameter is used to acquire the answer.

Once the mode is known, to switch modes the command SET DATABASE PARAMETER is used. However, just using the command is not enough. Once called the database has to be restarted for the change to become effective.

The method below makes it easy to determine if a database is running in UNICODE or Compatibility (Non UNICODE) mode and then provides an option to switch modes and if the database is running in Local Mode a chance to restart immediately.

If (True)
    If (False)
       //***************************************
       //
       // UTIL_Switch_UNICODE_Mode
       //
       //***************************************

    End if
    C_TEXT($MethodName_T)
    $MethodName_T:=Current method name

    //============ Declare Variables ============
    //local_variable_declarations
    C_LONGINT($unicode_L)
    C_TEXT($text_T)
End if
    //============ Initialize and Setup ============

$unicode_L:=Get database parameter(Unicode mode)
If ($unicode_L=1)
    $text_T:="Component running in Unicode Mode"
Else
    $text_T:="Component running in Non Unicode Mode"
End if

    //============ Method Actions ============

CONFIRM($text_T+"\rSwitch mode: ( RESTART REQUIRED )";\
    "Unicode mode";"Non Unicode mode")
If (OK=1) // Unicode
    SET DATABASE PARAMETER(Unicode mode;1)
Else
    SET DATABASE PARAMETER(Unicode mode;0)
End if

If(Application type = 4D Local Mode)
   CONFIRM("Restart now?")
   If(OK=1)
      OPEN DATA FILE(Data file)
   End if
End if