Template extension to be used in Global Embed (adding class object)

Hi Everyone,

Sorry, in my previous post edition, the template extension was dependent on a Joliciel_TemplateSet. I’ve modified the extension to be a template on its own can be used. Like I’m saying the error left that I’m investigating is on template errors.

The purpose here is to create a template extension with a MULTI attribute handling Global Object in its own tree within the Global embeds of the IDE like the File Manager, Fuzzy Manager, etc.….

I’m almost there; I’ve been able to create the extension where all instances are shown within the Global Embed. The code is generated with template errors caused mostly by %ClassItem symbols and instances of %ApplicationTemplateInstance. The code is generated entirely even with these errors. I believe the errors are dependent to the IDE itself. The program compiles without errors. I find this template extension must be perfectly created otherwise when there is changed at that level to the template extension the program will not load. Meaning I need to understand the process of this template extension. Below you’ll find more notes regarding the objective.

Here’s what is going on, the Global Embed Object of a class with multiple instances of the same class is working. Some test was done on five virtual child classes declared manually. I say this because, when %GlobalObject is set to “NO” the Class Item field is DISABLED. Meaning, one template for one class, this is not what I want to do. I’ve created the GlobalEmbedObject extension template child with a set of templates with the MULTI attribute on. The same extension can be reused.

The Global Embed shown all the virtual class in their own branch. The generated code of the applications was done successfully with five virtual child classes. Two of them had two instances of the same class. It generated with errors caused by %ClassItem symbol.

Here’re the template errors posted.

GEN: ASSERT: %ClassItem has no instance, jcL1 jcBase
GEN: ASSERT: %SetClassItem, instances not found: GlobalEmbedObject—[] for ClassItem:
TPL: (ABOOP.tpw) Error: Symbol %DefaultBaseClassType has no instance—C:\Clarion11\template\win\ABOOP.tpw:352
TPL: (ABOOP.tpw) Error: Symbol %ThisObjectName has no instance—C:\Clarion11\template\win\ABOOP.tpw:354.3
TPL: (ABOOP.tpw) Error: Symbol %ActualDefaultBaseClassType has no instance—C:\Clarion11\template\win\ABOOP.tpw:356

It seems that #CALL (%SetClassItem [ABC], “jc” & %ApplicationTemplateInstance). If this is not done the tree within the global embed is not shown. Maybe this is where I’m mistaken. Well, the application did compile without any error and run nicely.

#TEMPLATE(JoliClassGlobalManager,'Joliciel Class Global Manager Class Wrapper'),FAMILY('ABC')
#EXTENSION(JolicielClassManagerGlobalInstance,'Joliciel Class Global Manager instance'),MULTI,APPLICATION,DESCRIPTION('GlobalEmbedObject - ' & %ThisObjectName & ' An Instance Of: ' & 'jcBase' )
  #CALL (%ReadABCFiles(ABC))
  #SET (%UseDefaultABCBaseClass,%True)
  #SET (%UseABCBaseClass,%False)

  #CALL (%ReadABCFiles(ABC))
  #CALL (%SetClassItem(ABC), 'jc' & %ApplicationTemplateInstance)
  #CALL (%SetClassDefaults(ABC), 'jc','jc', 'jcBase')

    #WITH(%ClassItem, 'jc' & %ApplicationTemplateInstance)
#AT (%GatherObjects)
  #CALL (%ReadABCFiles(ABC))
  #CALL(%AddObjectList(ABC),'jc')	#!Add the template object 
  #ADD (%ObjectList, %ThisObjectName)
  #SET (%ObjectListType,'jcBase')

#AT (%GlobalData)
#CALL (%SetClassItem(ABC), 'jc' & %ApplicationTemplateInstance)
#INSERT (%GenerateClassDefinition(ABC), %ClassLines)

#AT (%ProgramProcedures)
  #CALL (%GenerateVirtuals(ABC), 'jc' & %ApplicationTemplateInstance, 'Joliciel Global Objects|Abc Objects| ' & %ApplicationTemplateInstanceDescription & '(' & %ThisObjectName & ')' & %ApplicationTemplateInstance, '%EmbedVirtuals(Joliciel_TemplateSets)')

#AT (%JoliClassManagerMethodCodeSection,%ApplicationTemplateInstance),PRIORITY(5000),DESCRIPTION('Parent Call'),WHERE(%ParentCallValid())
  #CALL (%GenerateParentCall(ABC))

#! -----  REQUIRED GROUPS  -----
#GROUP (%EmbedVirtuals, %TreeText, %DataText, %CodeText)
#EMBED (%JoliClassManagerMethodDataSection, 'Joliciel Class Manager Method Data Section'),%ApplicationTemplateInstance,%pClassMethod,%pClassMethodPrototype,LABEL,DATA,TREE(%TreeText & %DataText)
  #EMBED (%JoliClassManagerMethodCodeSection, 'Joliciel Class Manager Method Code Section'),%ApplicationTemplateInstance,%pClassMethod,%pClassMethodPrototype,TREE(%TreeText & %CodeText)

Thank you,


Finally, after some intensive work, I’ve been able to create the desired template. I find a way to make the template work nicely within the Global Embed of the IDE without templates and compiles errors. We can add as many class objects as we want, also multiple instances of the same class. In addition, for each instance of the template, we may set the compiler project definitions. It was very interesting as well as challenging to create.

In the Global Embed within the app contact example, you will find all template extension instances of the classes under Global Objects|ABC Objects|Joliciel Class. In each GlobalEmbedObject template extension instance, I’ve used the Clarion object classes as an example for the base class and the Contact solutions. Furthermore, use comments and local declaration methods and property within jcDB(dbAuditmanager) with some statements at the program set up in the main source and in the UpdateContact procedure; however, this is to see the declarations, sources code generation and running method class calls. If necessary, the project symbol needed for the compiler project options may be set within each template extension. The good thing having this assigns here we know which symbol definition represents the class of the embedded object and its status. You’ll find more notes about the template extension under,"Extension Important Note,” “Project Symbol Settings Explained,” “Export File Explained” Tabs.

You may download the template and application example on how it is implemented.
Here’s the GitHub link for the example and template source

  1. JolicielClassGlobal.TPL template file
  1. JolicielClassGlobal.TPW extension file
1 Like

This is a detail explanation of the template usage.


A Clarion Global Embed Object Class Template

The purpose of this template is to have globally as many as like to, class instances shown in the Global Embed Area of the IDE. This, the same way the Global Objects Error Manager (ErroClass) File Managers, Fuzzy Matcher (FuzzyClass), INI Manager (INIClass) and Relation Managers are presented. Meaning having a tree presentation of the class instance embed area. Moreover, also being able to create derived procedures within the class instances.

To repeat my self, this Clarion template will make it possible to add, as many as we like to, instances of a Clarion object class in the IDE within the Global Area. At the same time, we may create derive procedures within the instance itself.

For example, we want an instance of the AsciiFileClass from Clarion, by inserting the GlobalEmbedObject
extension template will permit to do so. By providing the following within the extension template window it will make it possible:

Object Name: AscIIFileObject
Base Class: AsciiFileClass
If the need to create a Derive class is required
By checking the Derive check box will permit as many as we like procedures within the AscIIFileObject class instance as well its Class Properties.

When we add these class instances, there is one thing important to know and understand. If we are compiling the program without doing anything else the compiler will post an unresolved or exception error. The cause of this, the compiler needs to know what to do, is it gone be in an exe or a dll. Therefore, we need to set the compiler LINK and DLL symbols’ directives in the Project Options Compiler Tab manually. This setting is shown in the Project sub menu. For many Clarion ABC classes the LINK compiler symbols directives is ABCLinkMode and for the DLL is ABCDllMode. If the program is an EXE, we need to assign ABCLinkMode=1 and ABCDllMode=0 otherwise, a DLL will be assigned in reverse
as ABCLinkMode=0 and ABCDllMode=1.

For the above reason the Project Compiler Symbol Settings area of the extension GlobalEmbedObject template is added. By checking “Enabling Project Compiler Symbol Settings” the Defined Symbols area will appear. This is where we need to add the LINK and DLL symbols of the class. Both the LINK and the DLL symbols needed to be set under; “Enabling compiler options” the radio button Link Mode or Dll Mode.

In our example
Defined Symbols
Link project compiler defined symbol : ABCLinkMode
Dll project compiler defined symbol: ABCDllMode

Enabling compiler options
“Radio button” Link Mode
“Radio button” Dll Mode

By selecting “Radio button” Link Mode will assign ABCLinkMode = 1 and ABCDllMode=0 otherwise if
“Radio button” Dll Mode is selected ABCLinkMode=0 and ABCDllMode=0

This aspect for which it is important to take care of, is the project compiler symbol directives must be set otherwise errors will appear.

However, it is important to read the tab notes regarding his usage. Actually, this may be applied to other areas that make changes to the Global Embed Area. One, if, for some reason, you need to delete an extension or a derive procedure or renaming the class instance, the need to save the app exit from the application solution and return to the session will prevent the IDE to crash. The reason for doing like so, if we are getting back right after doing the above changes to the Global Embed aread, the Clarion IDE will crash, like I said by saving the app session and reloading it, the change will be made and shown correctly.

Like said this template is taking care of the Project Compilier Symbol Settings. The only thing we need to know is what are the LINK and DLL symbols the parent class is using. The locations of these symbols are in the include files where the classes are declared. The folders where they are placed usually are in the Clarion\LibSrc\win and Clarion\Accessory\LibSrc\Win. Here in the below example, the file is located in the Clarion\LibSrc\win folder under ABASCII.INC file with the below header declaration. The symbol is an attribute of the class declaration here; the LINK attribute is ABCLinkMode and the DLL attribute is ABCDllMode.

Here’s where we see these attributes in the ABASCII.INC file

Below are the four tabs the first one is the setting and the others are explanatory

Class TAB

The first box is the Class Definition

Object Name: AsciiFileObject

Usually “Use Application Builder Class” is always check, this will make it possible to create an instance of a class. This way we may select our Base Class from the drop down menu

in our case
Base Class: AsciiFileClass
If we need Derive procedure by checking the Derive box will enable the creation of derive procedure and its properties.

The next box area of the Class TAB is the Project Compiler Settings
If the Projects Compiler Symbol Settings is enabled the values to the symbols will be added or modified to the Project Compiler Options

Checking box Enabling Project Compiler Settings
The following will be explained letter within the text.

If Export Project Compiler Symbol is Enabled only the Export project symbol is required otherwise a LinkMode and DllMode project symbols are required

By checking box “Enabling Export Project Symbol Setting” will make the alternative way to declare symbols directives.

The Export define symbols box appears we must provide a unique symbol and optionnally checking the box “Enabling export project if check”

Extension Important Note

When changing or deleting base class

  1. Regarding the Base Class, if, for some reason, we need to change or delete the ABC class from the GlobalEmbedObject extension, it may be done here. Before getting to the Global Embeds we must save the app, exit from the app solution and reload the application otherwise, the application in the IDE will crash.

  2. If other settings are changed, like renaming the class name or alteration to the project compiler settings, there is no need to exit from the application. We do not have to worry about getting back to the Global Embed. We may go directly to the area.

Understanding Project Compiler Symbol Settings

  1. Regarding Project Symbol Settings, if the same defined symbols are used in multiple GlobalEmbedObject extensions the settings must be identical in each extension instance otherwise error may occur.
    As an example if ABCLinkMode=1 and ABCDIIMode=0, therefore, all extension settings must be duplicated or the other extension Project Symbol Settings are unchecked meaning the assignment to the project definition is disabled. Like so, we are preventing the error occurring and the application will compile and run correctly.

  2. Base on what said about the point 1 above, only one project defined is sent to the project compiler defined symbols.

  3. The good thing having this assigns here we know which symbol definition represents the class of the embedded object and its status.

  4. If, for some reason, the compiler symbols are missing in the Project Compiler Options, and here the Project Compiler Symbol Settings is disabled; the application will not run the exception or an unresolve error will appear, unless some other area through the application is taking care of the defined compiler symbols.

Project Symbol Settings Explained

The compilation project symbol is required by the compiler.

The settings below will add the values under the Project Options Compiler Tab within the conditionals compilation symbols list.
A project symbol for a LINK set at 0 or 1
A project symbol for a DLL, set at 0 or 1

The ABC class the project symbols are when it is linked to an exe file,
for a DLL is_ABCDIIMode_ = 0
for a EXE is ABCLinkMode =1


  1. If the project symbol settings are not done here, it will need to be added within the Project Options Compiler Tab manually.

  2. Regarding the project symbol settings, if the same project symbol is reused in a multiple class object only one class object may enable the project symbol settings. The others may be disabled if not only a single class object that uses the project symbol ettings will be added to the compiler conditional project options.

  3. If enabled on multiple GlobalEmbedObject extensions, the settings to subsequent class object will be then only informative.

  4. When multiple class objects use the same project symbols settings if the choice is over Export Project Symbol, then subsequent GlobalEmbedObject extension must also enable the Export Project Symbol Setting with the identical value otherwise the compiler will generate duplicate messages over the project symbols.

  5. Regarding identical Export Project Symbol on multiple GlobalEmbedObject extension templates, the assignment must have the same state value otherwise an unresolved error will appear; the program will not compile successfully.

Export File Explained

The purpose having only one project symbols. When the export project symbol setting is set to 1 then the compiler will link to an exe otherwise to 0 it will compile as a Dll. This without the need, to create two defined compile symbols.

Example on an Export file on how its made

A file with the following equates that will represent the LinkMode and DIIMode of a class object Name of this file is jcClassProjectOptions.inc

Code in jcClassProjectOptions.inc

JCLinkMode EQUATE(0)

JCLinkMode EQUATE(1)

If the Export project symbol Setting is enabled, there is no need to assign and add values to the link and dll modes of a class object only the export project symbol. In the case above if JcClassProjectOptions_ = 1 the OMIT and COMPILE statements are executed otherwise the OMIT and COMPILE are not executed

The following INCLUDE statement is inserted at the top of the declaration file < FileNameOfClass.inc>

Code in FileNameOfClass.inc


1 Like

Just came across this post and will give the global template a try.

I am wondering if something similar has been created by anyone for use at the procedure
level? Such a template would add class virtual methods to the embed tree along with an
instance declaration for the procedure.

The template would easily & generically allow using any class one desires.
While It would be without the class specific prompts one gets from an accessory vendor, it would benefit the use of open source class code that is usually packaged without a template.

Yep, it’s been done. The Cape01.TPW and Cape02.TPW files exist as part of most of our products (including the free ones) and do all the generic class handling stuff that we need for all our class based products. Usage is documented (as comments inside Cape01.TPW) and covers all the bases - inheritance from multiple INC files, Interfaces, Managing Exports in DLL’s, Global Objects, Local Objects and so on.

If you’ve never bought a product from us I recommend StringTheory as being the most useful. It’s pretty ubiquitous anyway. (https://www.capesoft.com/accessories/StringTheorysp.htm) - but you don’t need to spend money - they are included with the free products as well (the most useful of which is like Reflection (https://www.capesoft.com/accessories/reflectionsp.htm) - but checking that now I see it Uses StringTheory, so for pure-free try GUTS (https://www.capesoft.com/accessories/gutssp.htm)

Oh, you get that too :slight_smile:


1 Like

I appreciate the directions toward a possible solution. I did quickly check the documentation inside and know it will take me, as an infrequent template tweaker, some time to get my head around the implementation.

I honestly believe the benefit to Clarion developers of this of generic template is something SV should provide with the product. It is an example of template enhancements that SV seems uninterested or incapable of adding over the many years of releases since ABC classes first appeared.

It’s available to all who want it. It doesn’t come from SV, but so what? What possible difference can it make whether it comes from them or not? At least from us it has lots of examples of use, it’s updated from time to time as needs require, it’s documented and I’ll happily talk about it in Wednesday webinars if anyone asks.

Whether it should be in the box or not is somewhat irrelevant.

I am not 100% sure we are thinking of exactly the same thing. Obviously, the commented code in cape01.tpw is not a procedure extension. How to perhaps adapt it for use as I envisioned (and to which my SV comment applies) will need to wait until I have time. I am confident many would welcome and hopefully benefit from a Capesoft demo.

Come to any Wednesday Open Webinar (https://us02web.zoom.us/webinar/register/WN_0pGfxlg9R8epJguLbcdwYA) and just ask, and I’ll show you.


Great, if you have any question do not hesitate to ask question, I’ll do my best to help you out.

Wish I had the time to pull it together at the procedure level. I had no trouble with manually adding a class & local procedures, but thought a simple template would be of benefit to developers in general. It also might help promote more open class code use.