This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
Command Line Interface

Command Line Interface  


 

 

You can use the macOS Terminal or the Windows console to drive your 4D applications (4D and 4D Server) using command lines. More particularly, this functionality allows you to:

  • launch a database remotely, which can be especially useful for administering Web servers.
  • run automatic tests for your applications.

You can execute command lines for 4D applications using the macOS Terminal or the Windows Console.

  • Under macOS, you should use the open command.
  • Under Windows, you can just pass the arguments directly.

Note: Under macOS, you can pass the arguments directly by going to the folder where the application is found inside the package (Contents/MacOS path), which allows to address the stderr stream. For example, if the 4D package is located in the MyFolder folder, you must write the command line as follows: /MyFolder/4D.app/Contents/MacOS/4D &. However, we recommend that you use the open command whenever you do not need to access the stderr stream.

Here is a description of command lines and the arguments supported to launch 4D applications.

Syntax

<applicationPath> [--project] [<projectPath | packagePath | 4dlinkPath> [--data <dataPath>]] [--opening-mode interpreted | compiled] [--create-data] [--user-param <user string>] [--headless] [--version] [--help]

ArgumentValueDescription
applicationPathPath of the 4D, 4D Server or merged applicationLaunches the application. Identical to double-clicking the 4D application. When called without structure file argument, the application is executed and the 'select database' dialog box appears.
--projectprojectPath | packagePath | 4dlinkPathProject file to open with the current data file. No dialog box appears.
--datadataPathData file to open with the designated project file. If not specified, 4D uses the last opened data file.
--opening-modeinterpreted | compiledRequests database to open in interpreted or compiled mode. No error is thrown if the requested mode is unavailable.
--create-dataAutomatically creates a new data file if no valid data file is found. No dialog box appears. 4D uses the file name passed in the "--data" argument if any (generates an error if a file with the same name already exists).
--user-paramCustom user stringA string that will be available within the 4D application through the Get database parameter command (the string must not start with a "-" character, which is reserved). 
--headlessLaunches the 4D, 4D Server or merged application without interface (headless mode). In this mode:
  • The Design mode is not available, database starts in Application mode
  • No toolbar, menu bar, MDI window or splash screen is displayed
  • No icon is displayed in the dock or task bar
  • The opened database is not registered in the "Recent databases" menu
  • The diagnostic log is automatically started (see SET DATABASE PARAMETER, selector 79)
  • Every call to a dialog box is intercepted and an automatic response it provided (e.g. OK for the ALERT command, Abort for an error dialog...). All intercepted commands(*) are logged in the diagnostic log
  • For maintenance needs, you can send any text to standard output streams using the LOG EVENT command. Note that headless 4D applications can only be closed by a call to QUIT 4D or using the OS task manager.
    --versionDispays application version and exits
    --helpDispays help and exits. Alternate arguments: -?, -h

    (*) Some dialogs are displayed before the database is opened, so that it's impossible to write into the Diagnostic log file (licence alert, conversion dialog, database selection, data file selection). In such case, an error message is thrown both in the stderr stream and the system event log, and then the application quits.

    These examples assume that your 4D application is stored on the desktop and that the database to be opened is found in the "Documents" folder.

    Note: The current folder of the user is reached using the "~ " command under macOS and the "%HOMEPATH%" command under Windows.

    • Launch application
      macOS:
      open ~/Desktop/4D.app

      Windows:
      %HOMEPATH%\Desktop\4D\4D.exe
    • Launch application with a package file on macOS:
      open ~/Desktop/4D.app --args ~/Documents/myDB.4dbase
    • Launch application with a project file
      macOS:
      open ~/Desktop/4D.app --args ~/Documents/myProj/Project/myProj.4DProject

      Windows:
      %HOMEPATH%\Desktop\4D\4D.exe %HOMEPATH%\Documents\myProj\Project\myProj.4DProject
    • Launch application with a project file and a data file
      macOS:
      open ~/Desktop/4D.app --args --project ~/Documents/myProj/Project/myProj.4DProject --data ~/Documents/data/myData.4DD

      Windows:
      %HOMEPATH%\Desktop\4D\4D.exe --project %HOMEPATH%\Documents\myProj\Project\myProj.4DProject --data %HOMEPATH%\Documents\data\myData.4DD
      or:
      %HOMEPATH%\Desktop\4D\4D.exe /project %HOMEPATH%\Documents\myProj\Project\myProj.4DProject /data %HOMEPATH%\Documents\data\myData.4DD
    • Launch application with a .4DLink file
      macOS
      open ~/Desktop/4D.app ~/Desktop/MyDatabase.4DLink

      open "~/Desktop/4D Server.app" ~/Desktop/MyDatabase.4DLink

      Windows
      %HOMEPATH%\Desktop\4D.exe %HOMEPATH%\Desktop\MyDatabase.4DLink

      "%HOMEPATH%\Desktop\4D Server.exe" %HOMEPATH%\Desktop\MyDatabase.4DLink
    • Launch application in compiled mode and create a data file if not available
      macOS:
      open ~/Desktop/4D.app ~/Documents/myBase.4dbase --args --opening-mode compiled --create-data true

      Windows
      :
      %HOMEPATH%\Desktop\4D\4D.exe %HOMEPATH%\Documents\myBase.4dbase\myDB.4db --opening-mode compiled --create-data true
    • Launch application with a project file and a data file and pass a string as a user parameter
      macOS:
      open ~/Desktop/4D.app --args --project ~/Documents/myProj/Project/myProj.4DProject --data ~/Documents/data/myData.4DD --user-param "Hello world"

      Windows:
      %HOMEPATH%\Desktop\4D\4D.exe --project %HOMEPATH%\Documents\myProj\Project\myProj.4DProject --data %HOMEPATH%\Documents\data\myData.4DD --user-param "Hello world"
    • Launch application without interface (headless mode)
      macOS
      open ~/Desktop/4D.app --args --project ~/Documents/myProj/Project/myProj.4DProject --data ~/Documents/data/myData.4DD --headless

      open ~/Desktop/MyBuiltRemoteApp −−headless

      Windows
      %HOMEPATH%\Desktop\4D\4D.exe --project %HOMEPATH%\Documents\myProj\Project\myProj.4DProject --data %HOMEPATH%\Documents\data\myData.4DD --headless
      %HOMEPATH%\Desktop\4D\MyBuiltRemoteApp.exe --headless



    See also 

    Headless 4D applications (blog post)

     
    PROPERTIES 

    Product: 4D
    Theme: Managing 4D databases

     
    PAGE CONTENTS 
     
    HISTORY 

    Modified: 4D v17 R3
    Modified: 4D v17 R6
    Modified: 4D v18 R5

     
    ARTICLE USAGE

    4D Design Reference ( 4D v20 R7)