2 - Creating a Data Dictionary

Top  Previous  Next


This section teaches you how to:


Create a new data dictionary.


Copy and customize table definitions from the Getting Started data dictionary to the new one.


Relate the tables and specify Referential Integrity constraints.


Pre-format window controls for the columns.

This lesson assumes that you have completed the Getting Started Lessons.


Lesson Files

We recommend that you complete the entire series of lessons here, regardless of your experience with Clarion. There are many new things you need to know about. As you’ve already seen from the Getting Started lessons, Clarion’s template-driven Application Generator approach to programming is very different from other development environments for 3GL and 4GL languages. If you’ll thoroughly immerse yourself in the following lessons, you will get the most out of your new tool.

The completed lesson files reside in the Shared Documents section on your computer.

For example, in Windows XP, the Lessons folder is found in:

C:\Documents and Settings\All Users\Documents\SoftVelocity\Clarion7\Lessons\LearningClarion\Solution


In Vista:



As of Version 7.1, the Examples and Lessons are provided as a separate install, so you now have the option to install wherever you want.

We provide these so you can see the end result of the lessons and compare your application. There should only be cosmetic differences.


Who should do these lessons?

If you’re already an experienced Clarion programmer, you may want to just examine the completed lesson files rather than step through the individual lessons. However, we do recommend that you at least read through the lessons, since there are methods of working in the development environment that the lessons demonstrate that may not be obvious just by "plunging in" and working with the tools—the lessons "show off" some features of the development environment that may not be readily obvious at first glance.

If you are coming from legacy developed applications (Clarion templates) and wish to learn more about ABC based applications, then these lessons are strongly recommended, regardless of Clarion expertise.

Wherever there are multiple ways to accomplish a single task, the lessons will expose you to several of them to demonstrate the flexibility of the Clarion development environment.


Creating the Dictionary

Whenever you create a new application, you first define the data dictionary (.DCT file). From the data dictionary, the Application Generator obtains all its information about the tables your application uses, their relationships to one another, plus additional information such as predefined formatting for controls.

As a general rule, the more forethought and work you put into designing your data dictionary, the more Clarion’s template-driven Application Generator can do for you. And, the more work the Application Generator does for you, the less you have to do yourself!

This chapter continues the examination of the Dictionary Editor that you began in the Getting Started lessons.


Starting Point:

You should have the Clarion development environment open and the Start Page opened.


Fill in the name of the new data dictionary


Navigate to the Dictionaries section of the Start Page, and press the New Dictionary button.

The Save As dialog appears.


Name the new dictionary file


In the Save in drop list, navigate to the …\Lessons\LearningClarion directory.


Type LCLesson in the File name entry.

Clarion appends the file extension; LCLesson.DCT is the full name for the dictionary file.


Press the Save button to create the file.

This creates an empty dictionary file. The tab of the Dictionary Editor shows the file name.


Specify a description for the dictionary


Press the Dictionary Properties button (located in the DCT Explorer toolbar).


The Dictionary Properties dialog appears.




Select the Comments tab, press the Add button in the toolbar, and then type Learning Clarion Lesson Dictionary in the text field.

The Comments tab allows you to write free form text notes regarding the dictionary. It’s optional, but extremely useful for programmers who may have to return to a project for maintenance after an interval of months.



Close the Dictionary Properties dialog by pressing the OK button.


Just to the right of the Dictionary Properties button on the DCT Explorer toolbar, there is a Users button which opens a dialog where new users can be added if needed. The dialog also provides a Password entry, which allows you to prevent others from using this dictionary. There’s no need to fill it in for this lesson, but it’s a useful feature to keep in mind.


Copying Tables From One Dictionary to Another

You can use the standard Windows copy and paste commands to copy table definitions from another dictionary (or to copy columns from one table to another). In other words, once you’ve defined it once, why bother to re-define it when you can just copy what you’ve already done!

There is also a better and recommend way to copy table definitions from one Clarion Dictionary to another, by using the Table Import Wizard. We will use this better method in this exercise.


Import Tables from the Getting Started Dictionary



From the DCT Explorer, select the Import Tables option found on the DCT Explorer toolbar. Press Yes if you are prompted to save changes to the Dictionary.



The Table Import Wizard appears.


Verify that the Select Server selection is set to Clarion Dictionary. Press the ellipsis button to the right of the Select Dictionary prompt (or, you can simply press the Next button below) to select the dictionary to import.



The Select Dictionary dialog opens, allowing you to select the other Clarion Dictionary to import from.



Select the GSLESSON.DCT located in the CLARION7\GettingStarted\Solution folder, and press the Open button.


The Select Tables from… dialog appears:





Press the Add All button to move all tables in the GSLesson dictionary to the new LCLesson dictionary, and then press Finish to complete the import process.



Relating the Tables

The beauty of using the Table Import Wizard is that all of the work that you did in that Dictionary, picture tokens, key attributes and relationships is preserved with the import. You can also copy (CTRL + C) table definitions (including their keys) from one DCT to another, but Clarion cannot copy the table relationships from other dictionaries. Therefore, you must re-define the relationship for tables,.if you use the Copy/Paste technique.


Before we leave this section, we need to add one other small change to our new LCLesson dictionary.


Set a default value


Select the CUSTOMER table in the DCT Explorer, and in the Fields Quick View, double-click on the STATE column. The Entity Browser and Column Properties is opened:




Select the Attributes tab.


Type ‘FL’ in the Initial Value entry (including the single-quote marks).

This specifies that anytime the control appears, its default value will be "FL." Initial values can be time savers for the end user; in this case, if most customers were located in "FL," it saves picking it from the list each time a new customer has to be added. The single-quote marks are necessary because you can also name a variable or function as the initial value of a column in a table (be aware that there are slightly different rules for initial values of memory variables). In this case, the initial value is a string constant, as identified by the single quote marks around it.


Press the Save and Close button in the Entity Browser toolbar to close the Column Properties dialog, and the Customer table.


Choose File  Save, or press the Save button on the IDE tool bar.


OK, What Did I Just Do?

Here’s a quick recap of what you just accomplished:

 You created a new, empty data dictionary (.DCT).

 You imported existing table definitions from one data dictionary to another (the easy way to work—never re-invent the wheel).

 You added an initial value for one of the columns in the database.

In the next chapter, you’ll learn how to add a table to the data dictionary, starting totally "from scratch". You’ll see just how quick and easy it is to do even without using a wizard.


Click here to jump to the next lesson