Error: Only up to 6 modules are supported in this layout. If you need more add your own layout.

This is a little trick I tried a while back with a ClarionAddins client. They were having an installation problem which was a little tricky to diagnose when it occurred to me that the log4Net library used in the Clarion IDE can send data pretty much anywhere with the right appender. A little bit of looking around I came across Papertrail (affiliate link!) which serves my needs very nicely for now in the free version and is decently priced if traffic goes up.

The basic idea is this: Add the appropriate log4net appender to the Clarion.exe.config file, repeat the problem you are having with the IDE, let me know when you are done and I will check out the logs and see if there is anything I can spot that needs attention.

Disclaimer: Of course you will remember to back up any configuration files before you make changes right?

Step 1: Enable sending logs

(do this bit with the IDE closed!)

A while back I released a free addin that puts a Clarion Evaluate PAD in the IDE. Prompted by a user I was reminded that this needed an update to be compatible with the later versions of Clarion (it was compiled with C8). The reason for this is that the Clarion IDE itself uses the ClaRun.dll and once it has loaded that DLL into the .NET AppDomain anyone else who wants to load a Clarion DLL within that domain needs to make sure they are compatible with that runtime version. I spent a few hours looking at running in a different domain and various other tricks but as far as I can understand you are pretty much stuck with whatever is loaded first when it comes to LoadLibrary kind of calls. No biggy, I think this is a better solution anyway!

Plus… you can now use any valid Clarion Evaluate statement from the command line using the new app I made for use with my addin.

I have uploaded it to GitHub, included a C# .NET solution showing how you can use it from there.

Go take a look!! – https://github.com/fushnisoft/ClaEvaluate/

 

Command prompt demo

Oh, I found this great PDF with good Evaluate examples in case that is of any use to anyone: http://www.schoeffler.biz/download/evaluate.pdf

 

-brahn

This last week I have had my head buried in a project to merge several databases into a few common ones. One of my clients is finding that a lot of smaller companies are combining their presence for various reasons and with it comes the need to merge what were previously very separate installations. Blah, blah, that is the boring stuff. What it means is that I have to do a bunch of things to make it work. These programs have a long history and as you can imagine with the “evolving” nature of vertical market software they also have a lot of baggage in their implementation. From what I have seen this is just a fact of life. It sure does make for some interesting jobs though!

If I get a chance I might try to blog about some of the other techniques I learnt while working on this project. Lots of SQL manipulations that are pretty cool, lots of mistakes and back tracks and lots of things I just wish there was a tool that could do the job for me. First though, this is something that I hacked together using powershell to rename a directory full of word documents that had a unique identifier embedded in the name.

The Situation

Two databases were being combined, Client records in database A would remain as they were. All Clients from Database B were copied into database A and received a newly generated SysID (Identity column) when they were inserted. The original SysID was stored in a column of the Clients table (ReferralSysID) for later reference. It could have been a temp table but this old ID was going to be needed for other things so it was decided to put it in the table itself.

Something about LibMaker I forgot to mention.
The libmaker source that ships with Clarion has a couple of problems with “Unmanaged Exports” DLLs. It only works with short filenames and it prefixes the labels with a “\”. These can be easily fixed in the source of LibMaker but I have created a compiled fixed version that should do the job.
Alternatively use the LoadLibrary API to dynamically load the DLL http://www.clarionmag.com/search/find?searchTerm=author%3Asand+loadlib  (sub required).

What?

ClarionMag article –Mixing Clarion with .NET, Part 1

“To call any .NET procedure from Clarion, you have a few choices. You can expose any .NET class to COM, which makes it visible to any COM client. Once you’ve done that, you can either use Clarion’s OLE control or write some Clarion wrapper classes.” “You can also make a Managed C++ wrapper, which is stored inside your .NET assembly. You then call this wrapper the same way you would call an API function.”

Robert Giesecke – C# Project Template for Unmanaged ExportsVisual Studio C# Project Template to “export managed code to native applications without the need of COM registrations”

And finally, a similar technique using Clarion# – http://clarionsharp.com/blog/2011/05/clarion-net-update-2/

Why?

Using .net allows you to tap into the vast amount of examples and libraries available in the .net world to help you create solutions. There is significantly less need to try and take a C++ or C# example and translate it to clarion code and API calls when you can just wrap up the functionality you need in .net and call it from clarion.

Unless you need to embed .net user controls in a clarion window I cannot see any reason not to use the DLLExport technique. It has the advantage that you don’t need to register the .net assembly using regasm.exe and is likely much faster to execute.

Color picker example

This example uses the Zeta Color Editor from an article on The Code Project website. The same editor is used in my InsertClarionColor addin.

ColorPicker.zip – Clarion 8 and Visual studio C# solutions. (one day I will move it to GitHub!)

  1. Create a C# project using the Unmanaged Exports template in visual studio
  2. Export a method that can be called by clarion which handles the calling of the editor dialog
  3. Create a clarion friendly lib file from the .net dll
  4. Create a clarion project to use the dll!

I had been using the C# Project Template for Unmanaged Exports quite a lot and while upgrading a project to VS 2012 I noticed that it is now available as a nuget package. There is only one catch… make sure your project has a specific CPU target set. It took me a little while to work that one out, otherwise the nuget package works perfectly. Go get it and start integrating .NET with your Clarion projects now!! Smile