Posts tagged: COBOL

Microsoft Visual Studio LightSwitch

By spgennard, August 4, 2010 10:01 pm

When I first started working on COBOL I was told that COBOL was a business oriented language that even managers could use ;-)

It looks like Microsoft are wanting to do something similar in a modern manor using Visual Studio + supper duper templates…

Here is what Computer World UK has to say about “Microsoft Visual Studio LightSwitch”.

Microsoft turns on Visual Studio LightSwitch

Visual Studio LightSwitch is easy enough for business managers

Microsoft is gearing up to release a version of its Visual Studio integrated developer environment that it promises will be easy enough for even business managers to use.

I understand this is not COBOL but the reasons sound very familiar…

From: Computer World UK – Microsoft turns on Visual Studio LightSwitch

Microsoft Visual Studio LightSwitch

Extending Visual COBOL 2010

By spgennard, July 1, 2010 9:08 pm

One of the many great reasons for choosing Microsoft Visual Studio 2010 as our development platform for Visual COBOL 2010 is it ability to be extended… which we have done but you equally use third party extensions too.

One of my favourite extensions is the spell checker for the editor, which is great for pointing out spelling mistakes, which for me can only be a good thing :-)

To install the extension, it is as simple as downloading it, clicking on the downloaded file, restarting Visual Studio and using it.

The spell checker I use with Visual COBOL 2010 is:

http://visualstudiogallery.msdn.microsoft.com/en-us/7c8341f1-ebac-40c8-92c2-476db8d523ce

For those interested, here it is in action…

Method Chaining

By spgennard, May 28, 2010 12:50 am

Creating objects with a complex constructor can be a bit of a pain in any language. One technique I have used is method chaining. It is not applicable to every type of class but it can be useful.

Method chain can help simply the use class and allows more complex object initialisation without having to worry about the order of the parameters and be done inline.

Consider the use of an “Account” class that takes Name, Address, Telephone and Country. All of which are strings, the constructor with four strings would not be a great constructor.

So you could have a simple constructor and four properties/methods.. however so set up the object would mean you have spread the setup over multiple lines.

Using method chain you can overcome this and even space in the “value” area of the object in your storage area.

set x to new type Account::Name("xx")::Address("yy") ::Telephone("yy")
     ::Country("zz")::World("Earth")

The trick of the pattern is to provide methods that always return this/self, so we can change the invokes together… For example:

This technique could even be used to build up a series of items required, for example, the preparation and execution of a sql statement comes to mind… in a similar fashion to Linq.

So… lets look at an example:

$set ilusing"System.Collections.Generic"
program-id. Program1 as "MethodChaining1.Program1".
data division.
working-storage section.
01 accounts type List[type Account] value new type List[type Account].      
01 jAccount type Account value
   new type Account::Name("Mr Johnson")::Address("Somewhere, some place")
    ::Telephone("+44 1234 4321").
01 sAccount type Account value
   new type Account::Name("Mr Smith")::Address("Nowhere place")
     ::Telephone("+44 1234 4321")::Country("Wales").                
01 lAccount type Account.
procedure division.
 invoke accounts::Add(jAccount)
 invoke accounts::Add(sAccount)
 
 perform varying lAccount through accounts
  display lAccount
 end-perform

 goback.
end program.

WIth the class being:

class-id Account.

working-storage section.
01 wName       string property as "Name".
01 wAddres     string property as "Address".
01 wCountry    string property as "Country".
01 wTelephone  string property as "Telephone".
01 wEmail      string property as "Email".

method-id New.
local-storage section.
procedure division.
  set wCountry to type System.Globalization.RegionInfo::CurrentRegion::DisplayName
end method.

method-id Name public.
procedure division using uName as string
 returning ret as type Account.
  set self::Name to uName
  set ret to self
end method.

method-id Address public.
procedure division using uAddress as string
 returning ret as type Account.
  set self::Address to uAddress
  set ret to self
end method.

method-id Telephone public.
procedure division using uTelephone as string
 returning ret as type Account.
  set self::Address to uTelephone
  set ret to self
end method.

method-id Email public.
procedure division using uEmail as string
 returning ret as type Account.
  set self::Address to uEmail
  set ret to self
end method.

method-id Country public.
procedure division using uCountry as string
 returning ret as type Account.
  set self::Country to uCountry
  set ret to self
end method.

method-id ToString public override.
procedure division returning ret as string.
set ret to String::Format("Name:{0}, Address:{1}, Telephone:{2}, Email:{3}, Country:{4}",
     self::Name, self::Address, self::Telephone,
     self::Email, self::Country)
end method.
end class.

Which when run with Visual COBOL gives:

Name:Mr Johnson, Address:+44 1234 4321, Telephone:, Email:, Country:United Kingdom
Name:Mr Smith, Address:+44 1234 4321, Telephone:, Email:, Country:Wales

Visual COBOL @ Microsoft Teched

comments Comments Off
By spgennard, March 29, 2010 10:23 pm

The last couple of weeks have been very busy and it has unfortunately affected the amount of blog entries I have done but the good news I have plenty of new material..

So, what’s my excuse.. Well we have been counting down the internal builds of Visual COBOL and we are pretty much ready to ship which is a relief since we are going to launching it at the Microsoft’s Visual Studio launch parties in Las Vegas and TechEd in Bangalore April 12-14.

Personally for me I am quite excited because I will be going to Teched in Bangalore to help show off Visual COBOL.

If would like a look at some of the Visual Studio 2010 integration Micro Focus has is about to release, pop along to http://vs2010.microfocus.com/ and see for yourself. Better still, have a visit to teched :-)

I will finish the silly little blog with a link to a demo of Visual COBOL. Just because I’m proud of it…

ref: http://www.microsoftteched.in/
and http://www.microsoft.com/visualstudio/en-gb/products/2010/default.mspx

Reflection and COBOL

comments Comments Off
By spgennard, February 13, 2010 11:56 pm

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

Panorama Theme by Themocracy