Clarion (programming language)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Developer(s) JPI, Clarion International, SoftVelocity
Stable release 8.0 / August 30, 2011; 2 years ago (2011-08-30)
Operating system Microsoft Windows
Type Integrated development environment

Clarion is a commercial, 4GL, multi-paradigm, programming language and Integrated Development Environment from SoftVelocity used to program database applications. It is compatible with ISAM, SQL and ADO data access methods, reads and writes several flat file desktop database formats including ASCII, CSV, DOS (Binary), FoxPro, Clipper, dBase, or all SQL RDBMS databases via ODBC, MS SQL Server, Sybase SQL Anywhere and Oracle through the use of accelerated native database drivers, and XML, Clarion can be used to output to HTML, XML, plaintext, and PDF, among others.

One of the Clarion Development Environment's primary features is its use of "templates" which are used in conjunction with a code generator (named AppGen) to produce much of the repetitive, time consuming code that is typically required when producing an application. An "embeditor" shows the developer the code that will be generated and embed points where the developer can enter their own hand-code in the context of the template generated code. Advanced Clarion programmers can create their own templates, or edit the existing ones.


Clarion is historically notable as being one of the first computer languages for MS-DOS that provided a 4GL screen painter, report writer and native database access.

It is notable as being an early Computer-aided software engineering tool for MS-DOS with support for defining relationships between data and automatically generating application code. Later on, early releases for Microsoft Windows were historically notable for providing a screen painter and report writer, at a time when most programming languages for MS-Windows required the user to write code to create each screen.

Clarion is a data-centric language, meaning that its primary function is the management and manipulation of data. Thus the language has commands that deal directly with the reading and writing of databases. Database Tables are a native data type in the language. Reports, as a mechanism for data output are also a native data type of the language.


The first release of the Clarion language was a DOS product called Clarion 1.0 and was first released in April 1986. Clarion was created by Bruce Barrington, one of the founders of healthcare firm "HBO & Company" (later acquired by McKesson Corporation[1]), and a small team of developers. Barrington's goal was to create a language that would be compact and expressive, and would maximize the use of the memory-mapped screen of the IBM PC by creating a screen designer. Version 1 produced pseudocode; the initial release included a screen designer, an interpreter, an editor, and a debugger. Initially it supported databases composed of DAT files and Clarion’s proprietary ISAM file format. Bruce Barrington formed Barrington Systems and released version 1.0.

Clarion 1.0 required the use of a dongle, at a time when industry sentiment was turning against dongles, which was offset by the ability to create royalty-free applications. However the dongle was removed with the release of 1.1.

At the same time, an even more basic version was sold. Called Personal Developer, it was very limited in what the user could do, but was adequate for very basic database applications. And it was a fraction of the cost of Professional Developer 1.x.

Version 2.0, released in May 1988, was known as Clarion Professional Developer, or CPD, and included a component called Designer, which incorporated a data dictionary. CPD generated Clarion code based on the contents of that dictionary and a template called a "model file." Because the model file was a text file, it could be modified (in limited ways) to create custom code. The model file was implemented with the "browse and form" paradigm, where data is initially displayed to the user in list box, and updating is done via a form called via buttons associated with the list. Designer created all the essential of the CRUD (create, read, update, delete) code, and developers could enhance functionality by inserting code at specified points in the generated code, or by hand-coding new procedures. Clarion Professional Developer also introduced Language Extension Modules (LEMs), that could extend the Clarion language using modules compiled in other languages that were built to the LEM format. Clarion Software and many third-party tool developers created LEMs for all purposes, including an extension for connecting to other databases such as dBase, Clipper and Paradox.

CPD 2.x was a database solution with everything required for screens, reports, databases and help files. A version of Clarion 2.x for end-users, Clarion Personal Developer, was also released just for the business user creating his own personal applications. Around the same time period, Clarion released Clarion Report Writer. This was created as both a stand-alone product for end-users of Clarion Personal Developer and users of programs written by developers with CPD, and as a built-in program bundled with Clarion Professional Developer version 2.1.

In 1991 Barrington licensed compiler technology from a company called Jensen & Partners International (JPI).

JPI was founded in 1987 by Niels Jensen, who had earlier (1979 or 1981) been one of the founders of Borland. Philippe Kahn was the marketing personnel who built Borland around the $99 Turbo Pascal compiler. Niels and his team were working on a new compiler technology at Borland when Philippe Kahn decided to buy Wizard C, and call it Turbo C. Niels and several other developers left Borland and started JPI, where they continued to work on their compiler technology, christened TopSpeed, which they bought from Borland for $1.7 million.

Clarion Database Developer 3.0 (CDD) was soon released. It was a revolutionary product adding many features and technology that could create programs with a “Windows like” CUA (Common User Access) user interface. Much of the CDD changes fit well into the Windows programming paradigm and laid the groundwork for the future Clarion for Windows product.

The CDD IDE was completely new and based on the JPI IDE. It included many professional programmer quality tools: editor, project system, compiler, linker, visual debugger. Gone was the p-code of CPD. The JPI compiler for the Clarion language produced true machine code EXEs, LIBs and DLLs. Binaries could be compiled for Protected Mode allowing DOS programs to use extended memory breaking the 640KB barrier.

The Clarion 3.0 language was enhanced in many ways, e.g.: new data types (CSTRING, PSTRING, DATE, TIME, USHORT, ULONG), file driver system (e.g. Btrieve, Clarion, Dbase, FoxPro, Paradox), queues (tables) were enhanced, screen processing was enhanced for CUA. Code generation by Models was replaced by “templates” that had more features and were extensible. This allowed generation of much more robust and complex code.

With all this new power came complexity. Many existing users found the transition to CDD difficult. CPD was simple and easy to use which attracted many non-programmers that could build programs by answering questions. CDD was more suited to professional programmers. Programs could still be developed as easily, but the size and vast features of the IDE made it appear complex.

The first 5 patch releases of CDD were buggy to the point of being unusable, which caused so many users to abandon the product that it was nearly a complete disaster for the company. Clarion kept working on CDD and by version 3.007 it was usable.

Version 3.1 named Clarion for DOS (CFD) was released in 1995. This proved much more stable, but by this time there was little interest in DOS development tools. A significant feature was the TopSpeed file driver, an ISAM file format allowing all indexes and multiple data files to be contained in one disk file.

During this time the relationship between Clarion Software and JPI grew closer, and on April 30, 1992, Clarion merged with JPI to form an entity which would eventually be called TopSpeed Corporation. The employees at the TopSpeed Development Centre in London went to work on CDD and ironed out many of the bugs.

TopSpeed released Clarion for Windows version 1.0 (aka CW 1.0) in January 1995. The final 1.003 release was June 1995. The IDE was completely written as a Windows GUI and could produce Win16 EXE and DLL binaries to run under Windows 3.x. The language featured many enhancements required to support the event driven Windows user interface. A Clarion developer could easily create a multithreaded MDI application. CW 1.0 continued the database flexibility added in CDD as well as adding an ODBC driver allowing connection to SQL databases, or any source supported by ODBC.

The DOS monolithic template model was significantly enhanced in CW 1.0 and replaced by a model that allowed a window to use multiple templates (Extension, Control or Procedure templates). For example, in DOS a screen procedure could support browsing a single data table. Under CW 1.0 a Window could use multiple Browse Control Templates each one displaying a different table. This design change was a major improvement in the power of Clarion code generation.

Clarion for Windows version 1.5 (aka CW 1.5) was released September 1995, with the final 1.502 release January 1996. This version added support for creating native Win32 binaries for Windows 95 and Windows NT 4. The same source could target Win16 or Win32. The IDE remained 16-bit but added 32-bit compilers, linker and debugger.

Clarion for Windows version 2 (aka CW20) was released in June 1996, with the final 2.003 release March 1997. CW20 added classic object orientation to the language, including inheritance, encapsulation, virtual methods and overloading. CW20 enhanced 32-bit support, added ActiveX support and enhanced SQL support.

Clarion 4 (aka C4) was released December 1997, with the final 4.002 release May 1998. TopSpeed elected to skip the dreaded version number three (the official explanation was that CW 1.5 "should have been CW 2.0," so CW 2.0 "should have been CW 3.0", so let’s just call the next one version 4). Due to DOS development being dead the name dropped the "for Windows" title.

C4 came with a new template set and class library called "Application Builder Classes" or “ABC”. The original template set generated procedural code, which was becoming increasingly complex. The ABC template set generated far less code, and leveraged the class library, which contained most of the actual logic for windows, browses, forms, etc. C4 enhanced OOP by adding Constructors and Destructors (without parameters).

Clarion 5 (aka C5) was released May 1998, with the final 5.0B release June 1999. The product was split into Professional and Enterprise editions.

Clarion 5.5 (aka C55) was released August 2000, with the final 5.507 release January 2002. C55 added Interfaces to OOP.

Clarion 6.0 (aka C6) was released November 2003, and added direct support for pre-emptive threading.

Clarion 6.1 was released May 2004.

Clarion 6.2 was released May 2005.

Clarion 6.3 as released Jan 2006. Excluding patches this is the final release of the 16 bit Clarion development environment. The use of a 16 bit IDE produced some problems using current Windows technologies (ActiveX, OCX, COM, DOC, ...); however, note that the series 6.x of Clarion produces native Win32 executables (32-bit exes and/or dlls). Previous versions produced both 16-bit and 32-bit executables, the 16-bit support was dropped from the end-user product with version 6.0 of Clarion.

On April 13, 2009 SoftVelocity released Clarion 7 (aka C7). The new IDE will look familiar to SharpDevelop users; SoftVelocity obtained a commercial license for the SharpDevelop code and integrated Clarion's code generation and application generation technology. Major new features (other than the standard modern IDE features lacking in C6) include a build system based on MSBuild and backward compatibility with all releases of Clarion going back to Clarion for Windows 1.5.

C7 is still a Win32 development environment, but a beta .NET version of the Clarion language, called Clarion#, is available. Both Clarion# and C7 share the same IDE, although at present they are shipped as separate products. Unlike C7, Clarion# does not yet have a dictionary editor or application generator. When Clarion# goes gold it is expected that a single IDE will support both Win32 and .NET development.

The new IDE (in Clarion# mode) retains the ability to build .NET applications with VB.NET and C#.

On September 12, 2011 SoftVelocity released Clarion 8. It continues the line of Clarion 7 (the latest release was C7.3).

The actual running version (13 Jan 2014) is C9.0.10376


The programming language is similar to BASIC, Pascal, and COBOL. It avoids requirements like Pascal's requirement that every code block is contained in a begin-end block. Like Cobol, Clarion separates data declarations from code. The language was designed to make writing business database applications simple.

Clarion is somewhat different from many mainstream languages in having data file access, window and report structures, and printing commands built into the language.


Although the templates are editable, the template generated code is not, leaving the user with only fixed points (called embeds) to add their own coding, this is because of the emphasis on RAD (rapid application development). In practice this is a minimal limitation.

Even in the Enterprise Edition of the development environment, there is optional functionality which requires a separate purchase from the creating company (including but not limited to "IP Data Driver and Server", "In-Memory Database Driver", "Dynamic File Driver", "Oracle Accelerator","TPS ODBC Drivers") . See Soft Velocity.

As a low-level language there are a number of higher-level functionalities (e.g. FTP up-/downloading, communicating with web services,) which are not part of the language. These can be programmed using API's exposed by Windows (for example WinSock). Many third party offerings (Third-party developer) wrap up high-level functionality.

Despite the economic benefits of code-generation, Clarion has never appealed to the wider programming audience. Hence finding trained, experienced Clarion programmers can be difficult. Further, since Clarion is data-centric, it requires programmers familiar with database design concepts.

There are few available external Clarion publications. To balance this however Clarion itself is easy to learn, and has a very active usenet community.

! The absolute greatest element of the matrix is returned to caller as are its positions
! call by address is done with the * similar to C
x    LONG,AUTO  ! Loop variable
y    LONG,AUTO  ! Loop variable
m    LONG(0)    ! Maximum return value
OutMaxX = 1
OutMaxY = 1
LOOP x = 1 TO MAXIMUM(a[],1)
  LOOP y = 1 TO MAXIMUM(a[],2)
    IF ABS(a[x,y]) > m
      m = ABS(a[x,y])
      OutMaxX = x
      OutMaxY = y

Hello World[edit]

The simplest way to achieve this is with the built in message function that is similar to the windows MsgBox().

 MESSAGE('Hello World!','Clarion')

Here is another, requiring only a minimum of code. This example opens a window in the program and use ACCEPT to handle the events.

Window WINDOW('Clarion'),AT(, 124,72),GRAY
      STRING('Hello World'),AT(21,26),USE(?String1)

A more real world example uses a Clarion structure to declare a window and the Clarion Accept loop to process events from that window.

 PROGRAM                          ! Declares this is a main program procedure
 MAP                              ! Determines which procedures will be called
   HelloProcedure                 ! This is a procedure
   HelloFunction,STRING           ! This is a function, that returns a string
   ArgumentFunction( LONG pArg ),STRING ! This is a function that receives an argument
 HelloProcedure                   ! Executes the procedure
 MESSAGE( HelloFunction() )       ! Executes the function, as an argument to the MESSAGE
 MESSAGE( ArgumentFunction( 4 ) ) ! The MESSAGE is an internal function, a message dialog
 RETURN                           ! Explicitly ends the program
HelloFunction        PROCEDURE    ! The compiler spots the difference, based on the MAP
 RETURN 'Hello, World!'           ! This is how one returns a value
ArgumentFunction     PROCEDURE( LONG pArg )
 RETURN pArg * 2                  ! Clarion does automatic type conversion
HelloProcedure        PROCEDURE
Window                WINDOW('Clarion for Windows'),AT(, 222,116), |
                       FONT('Tahoma',8, FONT:regular),ICON('Hey.ICO'),SYSTEM,GRAY
                       STRING('Hello World!'),AT(91,22),USE(?String1)
 CODE                             ! Marks the beginning of executable code
 OPEN( Window )                   ! Opens the Window structure
 ACCEPT                           ! Main keyboard/mouse reading loop
   CASE EVENT()                   ! Any event was raised?
   OF EVENT:OpenWindow            ! Window is open and displayed
   OF EVENT:CloseWindow           ! Window is about to be closed
   OF EVENT:Accepted              ! Was it a control being accepted?
     CASE FIELD()                 ! If so, which control generated the event?
     OF ?CloseBtn                 ! the Close button generated that
       BREAK                      ! We just need to break the accept loop
     END                          ! End the control test branch
   END                            ! End the event test branch
 END                              ! End of the accept loop

Here is another example implementing a simple class to demonstrate Hello World, it was converted from the similar Delphi Wiki example.

HelloClassType  CLASS,TYPE
Run                PROCEDURE()
HelloText          STRING(80)
CHello          &HelloClassType   !Reference to class
  CHello &= NEW HelloClassType
  CHello.HelloText = 'Hey You Dudes!'
HelloClassType.CONSTRUCT          PROCEDURE()  !Class Constructor, fires on New
   SELF.HelloText='Hello World'
HelloClassType.DESTRUCT           PROCEDURE()  !Class Destructor
HelloClassType.Run  PROCEDURE()
Window WINDOW('Clarion'),AT(, 124,72),GRAY
  ?String1{PROP:Text} = SELF.HelloText

As mentioned, Clarion is Template driven when using the "AppGen". This means that the AppGen uses templates to "form" the generated application. The template presents choices to the developer so the developer are able to modify the generated code. The generated code is as said - not editable - but it has points in code where the developer can change behaviour, still being able to rerun the generator.

An example of the template code:

 #CODE(ShowMessageBox, 'Show a MessageBox to the user')
   #PROMPT('Message to show:', @s255), %TheMessageToShow
 !Code Generated by the template
 #EMBED(%EmbedPointBefore, 'The Developer can add code before the Message appears')
 #EMBED(%EmbedPointAfter, 'The Developer can add code after the Message has been shown')

Example Loop Array Code:

         VAR:CodScript = SCR:CodScript
         Loop Until Access:Variaveis.Next()
            If VAR:CodScript = SCR:CodScript
               Sp# = 1
               If Upper(VAR:Busca) <> Upper(VAR:Troca)
                   L# = Instring(Upper(VAR:Busca),Upper(Loc:Script),1,1)
                   If Not L#
                   Loc:Script = Sub(Loc:Script,1,L#-1) & VAR:Troca & Sub(Loc:Script,L#+LEN(VAR:Busca),Len(Loc:Script))
                   R# += 1
                   Sp# = L#+LEN(VAR:Busca)+1
               !message(Clip(Loc:Script) &' '& R# &' '& SP# &' '& L#)
         Loc:Script = Clip(Loc:Script)

See also[edit]


  1. ^ "Health Care Services Leader McKesson’s History | Our History". McKesson. Retrieved 2012-03-14. 

External links[edit]