Exercise Four - Add a Lookup File

Top  Previous  Next

In this lesson, we will now look at "fine tuning" the dictionary in the Dictionary Editor. This will directly affect how our application will be generated in Lesson Eight.


Highlight the Customer table and examine the Fields list. You should notice a State column. In the next sequence of steps, we will create a lookup table to allow a user to select from a list of valid state abbreviations. After that, we will "notify" the state column that a lookup is active.


In the DCT Explorer, highlight the Tables entry, and press the Add Table  button, located in the DCT Explorer toolbar.




In the Label entry, enter States in it, and then press the TAB key.


Press the TAB key again to accept Sta as the Prefix.

Next, you are prompted to choose a Table Driver.


Verify or select TOPSPEED from the Driver drop list, and press the TAB key.


Press the OK button to complete the new Table.


In the Fields Quick View pad, press the Add button, located in the toolbar.




Type State in the first row of` the Column Name entry, and press the TAB key.




This creates a column named State. This column is the link to the State column in the Customer table. Using the same column names makes it easier to link the two tables in a relationship. In the generated Clarion code, adding the table’s prefix to column labels (separated by a colon) creates unique names for columns with the same name in separate tables. Therefore, this column will actually be called STA:State, while the column in the Customer table is called CUS:State.

Clarion also fully supports a naming convention called Field Qualification Syntax. The prefix format above (STA:State) can also be represented as States.State (file label.field label).



In the Characters entry, type 2, or use the spin control, and press the TAB key.




Accept all other defaults, and press the OK button to complete the new column.

At this time another Column Properties dialog opens allowing you to enter a second column.


In the Column Name column, type StateName, and then press the TAB key.


In the Characters column, type 30, then press the OK button to complete this column.


At this time another Column Properties dialog opens allowing you to enter a third column. We are finished with this table’s columns, so press the Cancel button to exit this dialog.




Next locate the Keys Pad, and press the Add button, located in the toolbar.




In the Label column, Type StateKey.


In the Attributes group, check the Require Unique Value check box.

This specifies a key that does not allow duplicate entries, enabling you to have a unique state reference file for your customers. This allows us to create a Many to One relationship between the two tables (Many Customers live in one State).


Click on the Columns tab, and press the Add button, located in the toolbar. In the Select a Column dialog, highlight State and press select as shown below:




Press Cancel in the Select a Column dialog to close this window, and press the OK button to save this key. Finally, press Cancel again in the Key Properties dialog to stop adding additional keys and return to the main Dictionary IDE.




Press the Save button in the IDE toolbar at this time to save your work, and stay in the Dictionary Editor.


Exercise Five - Create the Lookup Relationship