1

Hi i have 2 questions:

I am currently learning clarion for a project that i need to do. Currently i am looking into scanners and clarion as the language for a windows mobile application.

The first issue i have is regarding the use of clarion with SDK DLLs from 3rd party vendors such as Opticon scanners DLLs and normal c#.net DLLS, how do i go about using/accessing these DLLs in clarion and call them in code. I've done quite a large amount of searching for answers about the above mentioned but cant find anything quite usable.

The second question: Clarion can use a normal clarion for windows application via a web browser with the application broker and skeletons provided by clarion, in clarion 9 i created an application that does that but after creating and running the application in the browser i instantly receive an error on the main screen created by clarions self generating code. the error is "Uncaught syntaxError: unexpected Identifier" from the segment below which is missing a plus sign.

function icAjaxSubmit(controlValue)
{
    getContent(form.action+"? @"+$('#ClarionForm').serialize()+"&"controlValue+"="+$('#'+controlValue).value);
}

The problem is i cant find anything relating to this on the internet nor can i find the file this is generated from in clarion directories and application directories, it is also not in the projects code self from what i could notice.

Any one that possibly know something regarding the first question or a possible fix to the second question?

Thanks Gideon

2 Answers2

2

First let me get this out of the way. If you can use any other language besides clarion, do it. Clarion is a dead end development platform, it does not scale to meet the needs of the enterprise. By itself Clarion lacks a lot of built in functionality which means you either need to shell out thousands of dollars for third party tools, or learn the Windows API at which point you may as well pick up C. Not to mention the third party tools often times lose support and won't be upgraded to meet the needs of later versions of Clarion.

However, if you decided that using Clarion is necessary...

To answer your first question. C# .NET dlls, cannot be called by clarion natively because .NET dlls are not the same format as standard windows unmanaged dlls. But you can access them through some minor modifications.

Best case scenario, you have access to the source code for the C# dlls in which case you can modify the source code and implement the unmanaged exports package by Robert Giesecke https://www.nuget.org/packages/UnmanagedExports

using this package you can annotate specific functions in your C# library to be exported in the dll so that native applications can call them.

Worst case scenario these are 3rd party C# dlls for which you don't have access to the source code. You can try to follow this guide http://www.codeproject.com/Articles/37675/Simple-Method-of-DLL-Export-without-C-CLI

Your second problem is a result of bad syntax, you are missing a concatenation operator in the code here

"&"controlValue

The whole call should be:

function icAjaxSubmit(controlValue)
{
    getContent(form.action+"?@"+$('#ClarionForm').serialize()+"&" + controlValue+"="+$('#'+controlValue).value);
}
tt9
  • 5,784
  • 6
  • 42
  • 65
2

Clarion is actually none of the above. I won't waste time explaining why. Those who know why, know why. Back to reality.

Calling external DLLs successfully (e.g. those written in languages other than Clarion) has a lot to do with the PROTOTYPE declaration of the procedure / function being called in the external DLL. A typical PROTOTYPE for an external function that receives a string parameter, and returns one, in Clarion, is:

Prototype:

(BSTRING),BSTRING,PASCAL,RAW,DLL(TRUE)

What is important is to create a .LIB file from the DLL, using LibMaker.exe, typically found in Clarion's BIN folder. Open the DLL, and save the .LIB into the project folder, together with the DLL. Then add the .LIB file as one of the project's resources, and when you declare your procedure / function call in your Clarion application, ensure that the "Module" is pointing at the ".Lib" file you included in your project. You do this by switching the view from "Procedure" to "Module", locating your declared procedure, and changing its module to point at the Lib.

After saving your project, go ahead and delete the .MAP file associated with the Clarion project, re-open, generate, make are run.

One point mentioned above that's really, really useful, is to use the "Un-managed Exports" library in any .NET code you may write (e.g. in C#), which will allow you to "Marshall" data types between Clarion calls to .NET class libraries, and return the correct data types.

When exporting Clarion procedures / functions to .NET (or any other language for that matter), be sure to pay particular attention to the "case" of the procedure / function name in the calling application -- it must match the exact case as it was declared in the Clarion application.

Lastly, don't be side-swiped by the "&" comment above -- "&" is nothing more that the equivalent "+" concatenator in languages like C# or VB.NET, and is really not worth focusing on; Know that you can, both export Clarion functionality in DLLs, or use exernal DLLs (.NET or not), relatively easily -- by (a) PROTYPE correctly (b) use BSTRING to represent strings (c) Use the "UnmanagedEXports" library when calling .NET DLLs, (d) pay attention to case when making Clarion functionality available to external languages -- like C# or Delphi.

Aja
  • 21
  • 3