How to compare DCT version using DCTVersioniser

This great little tool from @Mark_Sarson was released into the wild yesterday. I thought it might be fun to do a step by step and show how it can be used!

If anyone would like to test out a simple tool I have written to “start” helping with dct source control then give me a private PM.

My tool will allow you to select a dct and will create a respective json file, so xyz.dct will create xyz.json

json is much nicer to look through where wanting to know what changes you have made in your dct between versions.

Written in .Net and requires .net 4.5
@Mark_Sarson

Let’s take a look at it from the beginning!

Step 0 - Why?

I can be handy to know what has changed between one version of your DCT and another, particularly if you are using version control.
If you are doing any kind of continuous integration, automate it and you will have a very nice view into your DCT over time too!
Also, because cool right?!

Step 1 - Git Clone the Repo

Sure, you can just go grab the EXE but… boo, that is boring. Show us the code! :slight_smile:

So we are going to go to the GitHub repo and “clone” it to your dev machine.

If you have the GitHub windows desktop client installed this is super easy, just click on the button:

Basically that is it. The Github client will ask you where to put it and proceed to grab all the latest files.
Once you have that you can either fire up Visual Studio and build the project or go directly to the included bin\Debug\DCTVersioniser.exe and dependant DLL file.

Step 2 - Launch the DCTVersioniser

Find the EXE and run it:

The first time you run it you need to tell it where the Clarion Bin folder is:

This is stored in a reg key so you don’t have to do this again.

Step 3 - Select a DCT to export as JSON

Ok, so now for the fun part. The DCTVersioniser will take your DCT, run it through ClarionCL.exe to create a DCTX (xml) file and then push that through Newtonsoft.Json.JsonConvert.SerializeXmlNode to turn it into JSON. Neat!! :star: :fireworks:

Select a DCT

Wait for a few seconds

Marvel at people.json !

The output will appear in the same directory as your DCT with the extention json instead of dct and look a little something like this:

Again though, Why?

Ok, so for example I added a new field to a table in the people.dct and created before after diffs of both the DCTS (xml) files and the json output of DCTVersioniser

This is what the diffs look like using WinMerge.

DCTX Diff

JSON Diff

Now, imagine that the only change was from a STRING(20) to STRING(30).
With the DCTX version you have that embedded on line in amongst other things. With JSON that is much more readable IMO and way more helpful.

Thanks @Mark_Sarson !!

Part 2

Json Import to DCT

The tool allows you to go “the other way” as well, ie. from Json back to a DCT.

First a warning, this step will create a clarion dct with a filename that is the name used in the Json file. So if your Json file is People.json, then this step will create a dct file with the name of People.dct. Please take a backup before hand so that you can revert if necessary.

So to import your Json dictionary, start DCTVersioniser.

On the Dialog “Select DCT File for export or Json File for import” change the file type to Json and select the Json fole and click open.

Within a few seconds the DCT will have been created from the Json file.

The idea here, although I haven’t tested yet, is to allow a much more focused experience for source control. Merge the changes other developers have made to the dct in the Json file, then import all the merged changes into a new DCT and carry on your work.

I took two People.Json files, one create from the original dct, and one create from the dct where I had added a new field to the people table. I used beyond compare (which is my compare tool). This showed me the differences between the two files and allowed me to pull the changes from the second file into the first. I then used DCTVersioniser to import the original (merged) file, and then opened the DCT in clarion. The new field is now present in the people file.

Obviously this is a simple test, and not using git merging or anything like that. I would really appreciate if someone has the time to try that out and let me know the results.

Command Line

The final thing to note is that I have added a command line experience for the tool so you don’t have to use the file dialog’s at all, and obviously can automate things a little.

To call the tool from the command line you do the following

DCTVersioniser -c "name and location of ClarionCl.Exe2 -f “name and location of the dct or json file”

for instance.

c:\peopleApp> DCTVersioniser -c C:\Clarion10\Bin\ClarionCl.exe -f People.dct

This will create the Json file for the people dictionary.

c:\peopleApp> DCTVersioniser -c C:\Clarion10\Bin\ClarionCl.exe -f People.Json

This will create a new People.dct from the Json file.

I think that about covers everything.

Be sure to let me know how you get on, and happy versioning.


In the latest version, when versioning the json file, a second file can be exported to a DCT-History folder with a Date/Time stamp. This will then keep a history of your changes as you go. Just run the command line DctVersioniser -h first to turn this feature on or off. The feature is initially off.

1 Like