How do I add an open source template to my C10 project?

My friend Wolfgang recommended the following template to me:

I have read the manual on templates, but either I missed the bit about how to add a template to my project, or it isn’t there. I’m a newbie trying to cope with an avalanche of new concepts and ideas.

I tried copying GenTXA.tpl to to C:\Clarion10\template\win but that didn’t seem to make any difference.
I also tried to add it to the folder my project is in.

I’m sure I’m missing something really obvious. Please could someone explain what to do with this template so it becomes part of my program?

Hi DonnEdwards

There are as a minimum 2 template areas, Softvelocity / Clarion’s Standard area and the area recommended for Third parties. Best practice is to use third parties.
So copy the template file and supporting template releated information in there… example: C:\Clarion10\accessory\template\win

Once you have done that, fire up clarion IDE and go to register the template.

Once your there, click on “Register” and then go find the template you just copied to the third party Accessory area and open.
Once registered it will appear in the list.

Remember different templates have different ways of using them.
This one would probably be a Utility template.

Hope that helps.

1 Like

Thanks. Now I have the templates registered.

What do I do to activate the template in my project? It consists of a single “Fixer.clw” file and a “Fixer.exp” file (whatever that is). See screen shot below

The help file mentions

From a Procedure Properties dialog, add an Extension template by pressing the Extensions button. CLICK on an extension template from the list, then press the Select button.

I have looked everywhere in the menus and the C10 IDE but I can’t see anything that looks like a starting point for a Procedure Properties dialog.

In short - nothing. Templates are used with APP files, not hand-coded projects. So in this case, unfortunately, completely useless to you.

As a bit of background;
The term “Clarion” applies to many things. The IDE certainly. And the language. And you can certainly write “normal” code in the language, using the IDE, compile that to an Exe and run it. The language itself is reasonably clean, and has some nice features (including complex data types like QUEUE’s, FILE’s (Tables), VIEWs, WINDOWs and REPORT’s.)

Most people though do not use the language in this way. (Some do - some have very large hand-coded projects.) Most people use another “Clarion” thing - called the Application Generator (or AppGen for short.) To some people, if you talk about Clarion you are talking about AppGen.

AppGen takes a dictionary, and templates, and “user settings” for input and generates CLWs (etc) for output. The compiler (the bit you are using) then takes those CLW’s and compiles them in the normal way.

At first glance AppGen could easily be dismissed as another “code generator”, but in truth it’s an exceptionally powerful layer which focus’s on code reuse. It is, if you like, a “meta” language - (called the Template Language). Folks proficient in the template language are able to write code in such a way that it can be reuses in “any” application. Most often Templates simplify the task of instantiating objects, initialising them, and then having them interact with the rest of the procedure (or application.)

Most programmers do not write templates. You do not need to write templates to make use of AppGen since the system comes with a bunch of existing templates. I would suggest that perhaps 98% of Clarion developers have never written a template, and never will.

Using this system a less-proficient developer can add code to their system that they would not have been able to write themselves. They are, in effect, leveraging the code-quality of the supplier at both the “class” level but also at the “integrating into your program” level. There exist several, really successful, developers who write very little, or none-at-all, code of their own. Some (and they wouldn’t mind me saying this) would not be able to write a single line of code if you asked them to. This may seem strange (shouldn’t programmers write code?) - but Clarion has always been more focused on the result (shipping programs, getting paid) than on the process (getting programmers to write a lot of code.)

Of course the quality of the generated code is as good as the quality of the templates. The better your templates, the better your code. Not surprisingly, given the 25 years since Clarion for Windows appeared, there are a lot of templates floating around - some free, some commercial. The standard of template code, just like any code, varies.

Incidentally the use of templates does not restrict you to “only that code” - you are able to “embed” your own code into the generated code using the “embeditor”. Templates have techniques for creating places for you to do this (“embed points”) so Apps, and templates, are not the “end of the journey” but the beginning of it.

A “perfect” app would be one that maximises the use of “generic” (reusable) code - via templates and classes, and then adds the minimal amount of embed code possible to make the program you are wanting to make.


1 Like

As well as what Bruce said, I notice you are basing this on the SHOWIMG example code. I believe that example code is there to show how to integrate C (or C++) code with Clarion code. Note however that Clarion has an inbuilt Match command so there is no need for you to use the match.cpp file - you can do wild-card matches in native Clarion.


Geoff R

1 Like

Hi Geoff
I can’t get the Built in MATCH to do the same as MatchSet does.

I want to match file names with *.clw and *.inc. With MatchSet I just use .clw;.inc

With MATCH I tried

strBrowseExtensions = '*.clw|*.inc'
IF MATCH(loc:filename, strBrowseExtensions,Match:Regular+Match:NoCase)

But this doesn’t work. It always returns false. I also tried with the semicolon :thinking:

change strBrowseExtensions to ‘.clw$|.inc$’
That will work.

1 Like

It matches anywhere in the filename, not the extension at the end. So I added some code to find the extension before matching it:

        loc:filename = CLIP(ffq:name)
        n = INSTRING('.',loc:filename,-1,LEN(loc:filename))  ! find the dot in the filename
        loc:extension = SUB(loc:filename,n,LEN(loc:filename)-n+1) ! get the extension
        IF MATCH(loc:extension, strBrowseExtensions,Match:Regular+Match:NoCase)! Find matching file extension

updated regex to use $ to indicate the end of the string.

1 Like