For the last couple of months I have working on Visual Studio 2010 and this include Microsoft CLR v4 and I was recently asked how to write a test that determines at runtime which CLR is being used and what assemblies it uses. I replies would use reflection. So I dropped my friend a mega simple demo… and here it is.
$set ilusing"System.Reflection"
01 myAssembly type "Assembly".
01 usedAssemblyName type "AssemblyName".
set myAssembly to type "Assembly"::"GetExecutingAssembly"
display "My exe is " myAssembly::"FullName"
display "and is using CLR " myAssembly::"ImageRuntimeVersion"
display "and is loaded from " myAssembly::"Location"
display "the initial method of this program was "
myAssembly::"EntryPoint"::"Name"
display "This assembly references -> "
perform varying usedAssemblyName
through myAssembly::"GetReferencedAssemblies"
display "-> " usedAssemblyName
end-perform
And the output of the program is:
My exe is clrver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
and is using CLR v2.0.50727
and is loaded from d:\clrver.exe
the initial method of this program was _MF_ENTRYThis assembly references ->
-> mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-> MicroFocus.COBOL.Runtime, Version=3.6.0.0, Culture=neutral,
PublicKeyToken=0412c5e0b2aaa8f0
The use of scripting languages with other languages has increased over the last couple of years, from a simple case of interoperability, reuse of scripting code to allowing your code to customised via the user of external scripts. All of which are real world examples I have seen customers use.
Interoperability between languages is very important to COBOL environments just as much as other languages. Some platforms such as Microsoft’s .Net with their CLR makes life much easier by allowing all languages to share a common infrastructure ie: the instruction set and the VM (MSIL and CLR) along with a base class library to get you started.
Environments such as Sun’s VM (JVM) provide two different approaches to interoperability with Java, the first is via JNI/JNA and the second is producing bytecode that runs as is on the VM.
Although the Micro Focus COBOL compiler does not support JVM bytecode or Java source generation it does have support for invoking classes/methods via the OO invoke verb.
COBOL, JVM, Java, Scripting, Tips
|
COBOL, javascript, javax.script, JSR 223, Micro Focus, Net Express, ScriptEngine, ScriptEngineManager, Scripting, ScriptObject
12 Tips for using Micro Focus COBOL
As it is close to Christmas and I wanted to do something with 12 in the title, I’ve thrown together some useful if not un-ordered list of 12 things tips using Micro Focus COBOL.
Remember I am just a developer and just want to help fellow developers out
so…
Merry Christmas!
and here is my list…
- Use DLLs/Shared objects rather than .int code
- DLLs/Shared objects can be preloaded using:
01 my-ptr procedure-pointer.
set my-ptr to entry "sodllname"
Note; sodllname does not have the extension… let the runtime choose it for you!
- Use a good development environment such as Visual Studio or on Unix use Eclipse offering if you have a workstation, otherwise I personally use vim/gvim if terminal access is the only choce.
- Remember you have a great choice of platforms from Windows to Linux to a load Unix platforms, so choice is king. (did I say that…)
- Try using managed code (.Net) if you want to create WPF/WinForms or use WCF
- Interopability is great, so if you see a Java Class, .Net Class, COM object, ‘C’ function or a Web Service… use it! You can even mix unmanaged and managed applications..
Today my collegues Robert and Alex have finally
decided to publish a document that compares Visual Basic, C# and COBOL for .Net under The Creative Commons Attribution-ShareAlike 2.5 License.
Rather than doing a cut-paste job, here is a quote from alex, along with a link to the “real” article itself.
Enjoy.
Alex Turner said:
A Comparison Of .Net COBOL, Visual Basic and C#
Introduction
If you are a COBOL programmer wanting to learn C# or a VB programmer wanting to learn COBOL as a .net language (or any other combination of VB.net, C# and COBOL) then this is a good place to start.
Background
If you are a COBOL programmer wanting to learn C# or a VB programmer wanting to learn COBOL as a .net language (or any other combination of VB.net, C# and COBOL) then this is a good place to start.
It has often been noted that the richness of the COBOL language in its Micro Focus .net implementation is not well known. Robert Sales and I have worked on this document to help bring the language to peoples’ attention and to help people who need to work with COBOL on the .net platform.
This is a preview of
A Comparison Of .Net COBOL, Visual Basic and C#
.
Read the full post (220 words, estimated 53 secs reading time)
If you are interested in trying out some of my examples with a modern COBOL compiler.. let me give you a quote from a friend.
From: Twitter “Scot Nielsen said: Micro Focus COBOL for .NET and Visual Studio available here FREE for non-commercial.
The development environment/compiler can be downloaded from the Micro Focus Shop.
More information can be picked up from the Microsoft Visual Studio Gallery