Getting Started
Getting Started
Table of Contents
SoftVelocity Inc.
www.softvelocity.com
Trademark Acknowledgements:
ii
Table of Contents
Table of Contents
Table of Contents iii
Getting Started 1
Getting Started Lessons 3
Exercise One - Create the Dictionary 5
Exercise Two - Import Your Data 8
Exercise Three - Relate Your Tables 11
Exercise Four - Add a Lookup File 13
Exercise Five - Create the Lookup Relationship 19
Exercise Six - Set the Lookup Validity Check 21
Exercise Seven - Fine Tuning the Customer and Orders Tables 22
Exercise Eight - Generate your Program using the Wizards 25
Summary 31
Clarion Programming Concepts 33
What's Next? 41
Index 43
iii
Getting Started
Getting Started
Introduction
Clarion is an infinitely adaptable environment, written to offer fast solutions at every skill level:
from the business owner to the enterprise development team. Whatever your level coming in,
Clarion will help you take control of your company data—more cost-effectively, and up to ten
times faster than any other product out there today. Here‘s why…
1
Getting Started
the template so that it meets your needs exactly. You‘ll set "actions" for the templates at many
places in the upcoming lessons.. The lessons that follow in this document introduce you to all of
the Clarion RAD tools.
When you use the template interface to specify these behaviors, the Application Generator writes
the code (Clarion language source code) that implements the behavior for you—and the code it
writes for you is object oriented, built from Clarion‘s Application Builder Class (ABC) Library, so
the code is very compact and efficient. Using the templates, you can do an awful lot of custom
programming without writing a single line of source code by hand.
The breadth and scope of the Clarion language can seem imposing at first. The Language
Reference is several hundred pages. One of the great advantages of having the template system
plus the ability to write code by hand is that you can ease into the language—as slowly as, as
quickly as, as much as, or as little as you wish. If you don‘t like the way the templates solve a
particular problem—you can use it at first, just to have something to do the job. Later, you can
use the template interface, to modify it a little more to your liking. Finally, when you know the
Clarion language, you can write a solution yourself, and have complete freedom to do it your way
(Note: you can also buy third-party templates to solve problems yet another way).
Power users, who may not normally write programs, can easily do this.
No matter which level you intend to work at, you're going to work a lot smarter if you first work
through all of the lessons all the way to the end.
2
Getting Started
This should all take about thirty minutes—without any "coding" on your part. By the end of this
section, you‘ll have a complete application for a database containing three related tables.
Welcome! Let‘s get started!
Make sure that the Clarion IDE is loaded (started). Close any windows that may be opened at this
time. You can leave this help file opened, and task switch back and forth with the IDE windows.
3
Getting Started
4
Getting Started
Starting Point:
If not already opened, start Clarion from the install’s program menu. If it is your first
time, you may be required to enter your serial number. You should have the Clarion
development environment open and the Start Page closed. You may optionally close all
other IDE pads at this time, we will open them as needed throughout this lesson.
1. From the IDE Menu, choose View Show Start Page and click on the Dictionaries
section.
2. Press the New Dictionary button, and the Save As dialog window appears:
5
Getting Started
3. Use the Save in drop list to navigate to the Lessons\GettingStarted folder found in your
Shared Documents folder.
In Vista:
C:\Users\Public\Documents\SoftVelocity\Clarion7\Lessons
In the File name entry, type GSLesson.DCT. Press the Save button to load the Dictionary Editor.
The Dictionary Editor‘s main window should now appear.
6
Getting Started
7
Getting Started
8
Getting Started
That‘s the basics for a file import. Of course, there are many other options and techniques that
you can use to import data definitions, but we are only getting started.
To review, the dictionary will be used with the application generator to help match and locate the
data that we are planning to process.
At this time, your dictionary is auto-saved after the import, so let‘s proceed to Exercise Three.
9
Getting Started
10
Getting Started
The Relationship Properties dialog appears. This is where you define the relationship.
2. Make sure the Type drop list is set to 1:MANY.
3. In the Primary Key drop list, press the down-arrow key to display the choices, highlight
KeyCustNumber, and then press the TAB key.
This is the key on the Customer table (the One side of the relationship) that will be used to
link the two tables.
4. In the Related Table drop list, press the down-arrow to display the choices, highlight
Orders, and then press the TAB key.
5. In the Foreign Key drop list, press the down-arrow to display the choices, highlight
KeyCustNumber, then press tab.
This is the key on the Orders table (the Many side of the relationship) that will be used to
link the two tables.
Next, the linking columns in the keys must be "mapped" so the Application Generator can
know exactly which columns in the two tables are related to each other. Since we used
identical column names, this is easy.
6. Press the Map By Name button.
The linking columns between the two tables appear in the two Column Mapping list boxes.
This is one reason to name linking columns the same.
11
Getting Started
In the next lesson, let‘s create a new dictionary file from scratch, and examine the Dictionary
Editor in more detail.
12
Getting Started
2. In the DCT Explorer, highlight the Tables entry, and press the Add Table button,
located in the DCT Explorer toolbar.
3. In the Label entry, enter States in it, and then press the TAB key.
4. Press the TAB key again to accept STA as the Prefix.
Next, you are prompted to choose a Table Driver.
5. Select TOPSPEED from the Driver drop list, and press the TAB key.
6. Press the OK button to complete the new Table.
7. In the Fields Quick View pad, press the Add button, located in the toolbar.
13
Getting Started
8. 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).
9. In the Characters entry, type 2, or use the spin control, and press the TAB key.
10. 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.
11. In the Column Name column, type StateName, and then press the TAB key.
12. In the Characters column, type 30, then press the OK button to complete this column.
13. 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.
14
Getting Started
14. Next locate the Keys Pad, and press the Add button, located in the toolbar.
17. 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 on the next page:
15
Getting Started
18. 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.
16
Getting Started
19. Press the Save button in the IDE toolbar at this time to save your work, and stay in
the Dictionary Editor.
17
Getting Started
18
Getting Started
1. Highlight Customer in the DCT Explorer, then press the Add Relation button located
directly above the Relations view.
The New Relationship Properties dialog appears. This is where you define the relationship.
2. Make sure the Type drop list is set to MANY:1.
3. In the Foreign Key drop list, press the down-arrow key to display the choices, highlight
None, and then press the TAB key.
This is no key required on the Customer table (the Many side of the relationship). You will
always be "looking into" the States table and never the other way in this example.
4. In the Related Table drop list, press the down-arrow to display the choices, highlight
States, and then press the TAB key.
5. In the Primary Key drop list, press the down-arrow to display the choices, highlight
StateKey, and then press the TAB key.
This is the key on the States table (the One side of the relationship) that will be used to link
the two tables.
Next, the linking columns in the keys must be "mapped" so the Application Generator can
know exactly which columns in the two tables are related to each other. Since we used
identical column names, this is easy.
6. Press the Map By Name button.
The linking columns between the two tables appear in the two Column Mapping list boxes.
This is one reason to name linking columns the same.
If you did not have a matching column name, no problem! Simply double-click on the
Columns Mapping entry, and select the linking field from the popup window provided.
Since the table relationship defined is only in one direction, Referential Integrity
Constraints are not needed.
7. Press OK to close the New Relationship Properties dialog. Press Cancel to exit the
Relationship Properties dialog.
19
Getting Started
20
Getting Started
6. Press the Save and Close button to close the Customer table.
21
Getting Started
The more time spent fine tuning your dictionary, the more time you will save generating a
near perfect application using the various wizard tools!
22
Getting Started
23
Getting Started
24
Getting Started
Make sure that the Clarion IDE is loaded. Close any windows that may be opened at this
time. You can leave this help file opened, and task switch back and forth with the IDE
windows. In this lesson, the install folder is identified as Clarion7. If you decided to install
to a different root name, please substitute accordingly.
The Application Wizard generates entire applications based on the minimal information that you
provide in response to a series of Wizard dialogs that ask for one piece of information at a time.
25
Getting Started
2. Select the Clarion for Windows item in the left Categories pane, and navigate to the
Application Quick Start as shown above.
3. Verify that the Location is in the target …\Lessons\GettingStarted directory.
4. Type GSLesson in the Name field.
5. Uncheck the Auto create project subdir checkbox.
6. Press the Create button.
26
Getting Started
7. Press the ellipsis ( ... ) button to the right of the Dictionary File entry box.
The Select Dictionary dialog appears.
8. Highlight the …\Lessons\GettingStarted\GSLesson.DCT file and press the Open button.
9. Verify that the Application Wizard check box is checked, and then press the OK button.
The Application Wizard dialog appears.
27
Getting Started
15. From the IDE Toolbar, Generate Source, and Build and Run your application by pressing
the Start without Debugger button (shown below):
28
Getting Started
29
Getting Started
30
Getting Started
Summary
Let‘s recap what was accomplished:
In your new dictionary, we defined a Customer and Orders table using the dictionary Editor‘s
Table Import feature.
You used the Data Dictionary to quickly add another table definition.
You defined the relationship between the two tables and specified the Referential Integrity
rules governing the relationship.
You used the Application Wizard to create your first application, with added validation to the
Customer‘s State column.
In less than thirty minutes—without any "coding" on your part—you‘ve created complete
application for a database containing three related tables. That‗s a real accomplishment!
If you can do this much with Clarion‘s "shortcuts," what can you expect to accomplish with all the
other tools Clarion provides?
In this first lesson, you should notice the overall design flow: Dictionary changes, Application
changes, back to the Dictionary, back to the Application, and so on.
You will find that the more time that you spend on your dictionary design at the start, the less
modifications you will need on the application side.
In this Getting Started lessons, we have only scratched the surface into the power of the Clarion
development environment.
There are two other lessons contained in this folder. The files used for the Online User‘s Guide‘s
Debugger lesson can be found in the
…\Lessons\Debugger folder.
A lesson targeting the use of the Dictionary Synchronizer The files used for the Online User‘s
Guide‘s Synchronizer lesson can be found in the
…\Lessons\SQL folder.
31
Getting Started
32
Getting Started
Levels of Abstraction
There is a principle that, the further you can get away from the "bare metal" of the computer (pure
binary), the more productive you can be.
A Bit of History
The very first digital computers were programmed in binary, one machine langauge instruction at
a time, and the programmer‘s job was very difficult. Then Assembly language came along to
make the programmer‘s job easier by making the program code readable by a human being.
Each Assembly language statement generated exactly one machine instruction.
Early Assembly programmers noticed that they were consistently writing the same sequences of
instructions to perform standard tasks. Therefore, they created Third Generation languages
(3GL—like Fortran, C, PL/1, etc.) so that each 3GL statement would generate multiple machine
instructions for these standard tasks and make programmers more productive. By doing this, they
started operating at a higher level of abstraction away from the "bare metal" of the computer. The
drawback was that only "standard" sequences of machine code were generated, so some of the
total flexibility that‘s possible when you work directly in Assembly language was lost.
Present Day—4GL
This same basic process has occurred to bring about the advent of Fourth Generation languages
(4GL) like Clarion. For example, the Clarion language automatically handles all the standard
Windows chores (such as re-painting the screen) that programmers are required to write for
themselves in 3GL languages. In Clarion, a "Hello World" program is just 9 lines of source code,
while in C/C++ you must write over 80!
33
Getting Started
What is a Template?
In Clarion, a template is not just a "one-time" tool generating code that you must then maintain
yourself (like the things that some other languages call "templates"), but is a continually
interactive tool that asks specifically for the information it needs to generate your source code.
Changing the information you provide to the template causes different source code to generate
the next time you make your application. This interactivity makes Clarion‘s Templates the key to
Rapid Application Maintenance.
Clarion templates allow you to insert your own Clarion source code into their generated source at
any of the many Embed Points available to you within each template. This makes it unnecesssary
for you to maintain all the generated code in order to customize the procedure‘s behavior. It also
guarantees that your special customizations aren‘t overwritten the next time you generate
source—the template simply generates your code inside its standard code. This easy
customization makes Clarion‘s Templates the key to Rapid Application Enhancement.
All the templates are stored in the registry file (TemplateRegistry.TRF). This file contains the pre-
written executable code and data structures which you customize and reuse. You can use the
Template Registry to modify the design of each template‘s default window or report to the way
you want them to appear when you first create a procedure.
34
Getting Started
You can modify the Clarion templates. You may also add third party templates, or write your own,
and use them in addition to, and along with, the Clarion templates. This makes the Application
Generator an infinitely extensible tool.
35
Getting Started
Application Wizard
Generates a complete "standard" application for you in just minutes, based on the table
definitions and settings in your Data Dictionary.
Procedure Wizards
Generate "standard" procedures for you (like a Browse list, or data entry Form) based on the
settings in your Data Dictionary.
Procedure Templates
Generate "standard" procedures for you (such as the application Frame menu, or a Report),
based on the window or report design you create in Clarion‘s Window Formatter and Report
Formatter, and the options you select for the Template‘s prompts for information about your
procedure.
Control Templates
Add "standard" controls to your window or report design (such as a related tables Tree control)
and generate all the code needed to "drive" the behavior of the control.
Extension Templates
Generate additional code into a procedure to provide functionality unrelated to any specific
window control (such as a Date/Time display in the application Frame‘s status bar).
Code Templates
Generate code into a procedure that usually performs a single task related to a specific window
control (such as Data Entry validation).
Source Template
A Template which allows you to completely write your own Clarion language procedures while still
maintaining the application in the Application Generator.
36
Getting Started
Let the Application Wizard write a "starting point" application for you.
Modify what you need to in each Procedure Template using Clarion‘s two-way interactive
tools (like the Window and Report formatters).
Add Control, Extension, and Code Templates as you find you need their functionality.
When you find you need to do something that no template does for you, use the Source
Template and write it in the Clarion language (or get a third-party Template that does what
you need).
Dive all the way down to the Windows API and C/C++ levels only when you absolutely must.
This is the Clarion philosophy of working smarter, not harder, by letting the toolset do the
"drudge" work. Do this, and you‘ll find that your productivity soars compared to any other tool
you‘ve ever used.
This section provides a description of each tool, in the order that a typical programmer using the
Application Generator might encounter them. Each tool contains dialog boxes which the
programmer fills out to describe the Application‘s functionality to the Application Generator. On
your command, the Application Generator generates the specified source code, and the Project
System compiles and links it to make an executable program.
37
Getting Started
Common Tools
Programming in Clarion is, in many ways, a personal journey through a series of dialog boxes.
There is no mandatory sequence to follow through the dialogs, though some are prerequisites for
others. The following are brief descriptions of the tools common to both Professional and
Enterprise editions of Clarion.
38
Getting Started
The Debuggers
Debugging a program usually requires running the program and repeatedly stopping it at various
points during execution to examine the value of different variables to determine the cause of logic
errors in the program. The Clarion Debuggers (both 16-bit and 32-bit) have a number of windows
which display source code, variable contents, active procedures, and much more.
There are three lessons on using the Debuggers contained in the User‘s Guide. We recommend
that you go through them after finishing Getting Started and Learning Clarion lessons.
39
Getting Started
Dictionary Synchronizer
The Dictionary Synchronizer allows you to synchronize one data dictionary to another (available
only in Enterprise Edition). You can synchronize two Clarion data dictionaries (.DCT files), or
synchronize a Clarion data dictionary with an SQL back end‘s data dictionary (either direction).
This allows you to get all the table definitions and relationships at once from the SQL backend
database and eliminate a lot of front-end work and keep the Clarion data dictionary in synch with
the SQL RDBMS at all times, no matter what changes the SQL Database Administrator makes.
Dictionary Diagrammer
The Data Dictionary (a .DCT file), can also be maintained by the Dictionary Diagrammer (also
available as an add-on to Professional Edition). This is a visual data modeling tool, allowing you
to view your database design from an entity-relationship diagram perspective.
40
Getting Started
What's Next?
There are several directions that we would like to recommend:
1. The GSLesson application that we started here is greatly expanded with many of Clarion‘s
powerful templates and other features in the Learning Clarion section of this online help
file. These lessons are designed to introduce you to all the common development tools
Clarion offers in both Professional and Enterprise Editions.
2. Dive in and get started with your own projects. The Online User's Guide, accompanied
with the Clarion Core Help, provide comprehensive information to help you through your
particular projects.
3. SoftVelocity offers educational seminars at various locations. Call Customer Service at
(954) 785-4555 to enroll.
4. Join (or form) a local Clarion User‘s Group and participate in joint study projects with other
Clarion developers.
5. Participate in SoftVelocity‘s online newsgroups. SoftVelocity‘s internal news server offers
newsgroups for all SoftVelocity products. On this news server you can exchange ideas
with other Clarion programmers. Log into news.softvelocity.com and subscribe to the
groups for the products you want to discuss (Strongly recommended!).
6. In addition, there is a Usenet newsgroup—comp.lang.clarion— where you can network
with other Clarion programmers from all around the world. If English is not your native
language, there is alt.lang.clarion.
7. Good luck and keep going—the programming power that Clarion puts at your fingertips
just keeps on growing as you learn more!
41
Getting Started
42
Index
Index
Clarion Programming Concepts ................ 33 Ex. 6 - Set the Lookup Validity Check ...... 21
Getting Started............................................. 1 Ex. 7 - Fine Tuning the Customer and
Orders Tables ........................................... 22
Ex. 1 - Create the Dictionary ....................... 5
Ex. 8 - Create your Program using the
Ex. 2 - Import Your Data .............................. 8
Wizard ....................................................... 25
Ex. 3 - Relate Your Tables ........................ 11
Summary................................................... 31
Ex. 4 - Add a Lookup File .......................... 13
Getting Started Lessons ............................. 3
Ex. 5 - Create the Lookup Relationship ..... 19
43