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.
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”.
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)