Database Record Examples

Database Record Examples

  • Have different versions for different operatings systems (Windows, Linux) and be able to toggle between them by a simple command:

    EXAMPLE:

    • # Define default OS, using in '_hkey_init.txt'
      set new %OS_VER%    = WINDOWS
      # Define the control variable %USE_OS_VER%, defaulting to %OS_VER%
      set new %USE_OS_VER%  = %OS_VER%

        # Override %USE_OS_VER% with env var %_USE_OS_VER% if it has a value
      #ifdef  %_USE_OS_VER%
      set %USE_OS_VER%  = %_USE_OS_VER%
      #endif

        # Define keys that override the value of env var %_USE_OS_VER%,
      #    and therefore %USE_OS_VER%
      "ver.linux"   -> set _USE_OS_VER LINUX    -exec_asis echo _USE_OS_VER is '%_USE_OS_VER%'
      "ver.win"   -> set _USE_OS_VER WINDOWS    -exec_asis echo _USE_OS_VER is '%_USE_OS_VER%'

      # Windows-specific dbrecs
      #if %USE_OS_VER% == WINDOWS

          # Windows versions of dbrecs here...

      #endif

      # Linux-specific dbrecs
      #if %USE_OS_VER% == LINUX

          # Linux versions of dbrecs here...

      #endif

    EXPLANATION:

    • The first line defines a new Hyperkey variable %OS_VER% and initializes it to define the default operating system. Typically, this line would be in the initialization file '_hkey_init.txt'.
    • The next line defines a new Hyperkey variable %USE_OS_VER% and initializes it to the value of the default operating system set previously, %OS_VER%. It is this variable that will be used to enable or disable blocks of dbrecs.
    • The next block of dbrec lines overrides the value of %USE_OS_VER% with the value of environment variable %_USE_OS_VER%, if it is defined.
    • The next block of dbrec lines defines keys that set environment variable %_USE_OS_VER%, which in turn will override %USE_OS_VER% via the #ifdef %_USE_OS_VER% statement on the next Hyperkey command. It is these two lines that make it easy to toggle between the two versions.
    • The finally the OS-version-specific dbrecs are enclosed in '#if %USE_OS_VER% == xxx' statements.
Previous: Database Records