Log In    |    Knowledge Base    |    4D Home
Tech Tip: Automatically adding files to your merged application
PRODUCT: 4th Dimension | VERSION: 2004 | PLATFORM: Mac & Win
Published On: August 15, 2007

There are many files that a developer may want to add to a merged application. If the application is built using the Build Application Dialog in 4D, the files must be moved manually after building, or perhaps by manually executing 4D code that handles moving the files.

One of the huge advantages of using the BUILD APPLICATION command to create a merged application is that this process can be completely automated. Here is a method which demonstrates how to add a help file to a merged application, after first building the application:

  ` Method: Build_add
  ` This method is specific to windows machines and 4D Runtime Volume License Light
  ` Instructions for making changes follow


` First built the application.
$pathToProjectFile:=Get 4D folder(Database Folder )+"Preferences\\BuildApp\\BuildApp.XML"


If (OK=1)
  ` If the build was succesful, install the help file...

  ` The project file is used to figure out where the help file should be copied to...
  $elementRef:=DOM Parse XML source($pathToProjectFile)

  ` The XPATH for the build destination folder is used to get the value...
  $find:=DOM Find XML element($elementRef;"Preferences4D/BuildApp/BuildWinDestFolder")
  DOM GET XML ELEMENT VALUE($find;$pathToBuildDestination)

  ` Finally the Help file is copied to the correct location.
  COPY DOCUMENT($helpFile;$pathToBuildDestination+"Light Application\\Database\\"+$helpFile)
  ALERT("Build Failed!")
End if

Notice that the application build project file is used to get the correct path (from the "BuildWinDestFolder" XML key).

To change this from Windows to Mac the backslash separators (\\) must all be changed to colons (:) and the XPath must be changed from:




Depending on which 4D Runtime Volume License is used and/or which type of application is being built (single-user or client-server) the location of the merged application is different. The folder that is created during the build process is named differently for each type, as follows:

4D Runtime Volume License Light Standalone Application: "Light Application\\Database\\"
4D Runtime Volume License Pro or Sponsored Standalone Application: "Final Application\\Database\\"
Client Server Application: "Client Server executable\\Server\\Server Database\\"

Commented by Edgar Pigg, Jr. on August 19, 2010 at 1:04 PM
Beware of how relative path information stored in the project file is expanded when using Mac OS 10.6.4. If the BuildMacDestFolder is at the same level as your source application it will not expand correctly when using Create Folder or Copy Document commands. A key represented as ::ApplicationFolder: will not expand correctly. If the destination folder is in the source application folder, :ApplicationFolder:, will expand correctly. This applies to 4D v11 SQL 11.7. I have not tested this with other versions of 4D or operating systems.