A component to export the structure file

Thanks to 4D v17 R3, you can export your structure file in multiple text files. For example, with only a few lines of code you can create a copy of your database every morning. You can use this to keep track of the history or to send your database to a colleague and see the changes when they’re done working on it.

We provide you a ready-to-use component with only two methods: one to configure the data to be exported, and the other to export your database.

Source code of component

Configure the data

In this component, the “OpenDialConfigExport” method displays an interface to configure your export. The result is saved in a JSON file next to the host database structure.

For example, you execute:

// Display the configuration dialog
OpenDialConfigExport

Then select the elements to export:

When you click on the “Save” button, the following “configExport.json” file is created.

{
  "withLog": "ifNotEmpty",
  "filter": {
    "projectMethods": true,
    "databaseMethods": true,
    "triggerMethods": false,
    "forms": true,
    "catalog": true,
    "folders": false,
    "settings": false,
    "menus": false,
    "tips": false,
    "lists": false,
    "filters": false,
    "pictures": false,
    "resources": false,
    "trash": false,
    "windowPositions": false,
    "methodPreferences": false
  }
}

You don’t need to execute this command. If the configuration file doesn’t exist, the entire structure file is exported.

Export the structure

To export the structure file, use the ExportStructure component method. Pass the folder where the content is exported as parameter.

For example, you want to export a copy of your code in a folder named “YY-MM-DD hh-mm-ss”.

blank

Just write the following code:

C_TEXT($path)
$path:=System folder(Documents folder)+"Export"+Folder separator\
  +Path to object(Structure file).name+Folder separator\
  +Replace string(Replace string(String(Current date;ISO date;Current time);":";"-");"T";" ")+Folder separator
If (Test path name($path)#Is a folder)
  CREATE FOLDER($path;*)
End if
ExportStructure ($path)

 

Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.