<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The ramblings of a yorkshire tyke &#187; COBOL</title>
	<atom:link href="http://www.gennard.net/blog/category/cobol/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gennard.net/blog</link>
	<description>Life, Rants and Programming In A Blog</description>
	<lastBuildDate>Sat, 10 Jul 2010 23:04:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Extending Visual COBOL 2010</title>
		<link>http://www.gennard.net/blog/2010/07/extending-visual-cobol-2010/</link>
		<comments>http://www.gennard.net/blog/2010/07/extending-visual-cobol-2010/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 20:08:38 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[VisualCOBOL2010]]></category>
		<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Spell Checker]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=610</guid>
		<description><![CDATA[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&#8230; 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 [...]]]></description>
			<content:encoded><![CDATA[<p>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&#8230; which we have done but you equally use third party extensions too.</p>
<p>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 <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>To install the extension, it is as simple as downloading it, clicking on the downloaded file, restarting Visual Studio and using it.</p>
<p>The spell checker I use with Visual COBOL 2010 is:</p>
<p><a href="http://visualstudiogallery.msdn.microsoft.com/en-us/7c8341f1-ebac-40c8-92c2-476db8d523ce">http://visualstudiogallery.msdn.microsoft.com/en-us/7c8341f1-ebac-40c8-92c2-476db8d523ce</a></p>
<p>For those interested, here it is in action&#8230;</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="800" height="600" id="test1"><param name="movie" value="http://www.gennard.net/blog/wp-content/uploads/2010/07/2010-07-01_1558.swf" /><embed src="http://www.gennard.net/blog/wp-content/uploads/2010/07/2010-07-01_1558.swf" width="800" height="600" name="test1" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2010/07/extending-visual-cobol-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Method Chaining</title>
		<link>http://www.gennard.net/blog/2010/05/method-chaining/</link>
		<comments>http://www.gennard.net/blog/2010/05/method-chaining/#comments</comments>
		<pubDate>Thu, 27 May 2010 23:50:09 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[cobol.net]]></category>
		<category><![CDATA[method-chaining]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Visual COBOL]]></category>
		<category><![CDATA[visualcobol]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=591</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>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.</p>
<p>Consider the use of an &#8220;Account&#8221; class that takes Name, Address, Telephone and Country.  All of which are strings, the constructor with four strings would not be a great constructor.  </p>
<p>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.</p>
<p>Using method chain you can overcome this and even space in the &#8220;value&#8221; area of the object in your storage area.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000; font-weight: bold;">set</span> x <span style="color: #000000; font-weight: bold;">to</span> new <span style="color: #008000; font-weight: bold;">type</span> Account::Name<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;xx&quot;</span><span style="color: #339933;">&#41;</span>::<span style="color: #008000; font-weight: bold;">Address</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;yy&quot;</span><span style="color: #339933;">&#41;</span> ::Telephone<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;yy&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;::Country<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;zz&quot;</span><span style="color: #339933;">&#41;</span>::World<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;Earth&quot;</span><span style="color: #339933;">&#41;</span></div></div>
<p>The trick of the pattern is to provide methods that always return this/self, so we can change the invokes together&#8230;    For example:</p>
<p>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&#8230; in a similar fashion to Linq.</p>
<p>So&#8230; lets look at an example:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a0a0a0; font-style: italic;">$set ilusing&quot;System.Collections.Generic&quot; </span><br />
<span style="color: #008000; font-weight: bold;">program-id</span><span style="color: #000066;">.</span> Program1 <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;MethodChaining1.Program1&quot;</span><span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">data</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
01 accounts <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #000080; font-weight: bold;">List</span><span style="color: #339933;">&#91;</span><span style="color: #008000; font-weight: bold;">type</span> Account<span style="color: #339933;">&#93;</span> <span style="color: #008000; font-weight: bold;">value</span> new <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #000080; font-weight: bold;">List</span><span style="color: #339933;">&#91;</span><span style="color: #008000; font-weight: bold;">type</span> Account<span style="color: #339933;">&#93;</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp;<br />
01 jAccount <span style="color: #008000; font-weight: bold;">type</span> Account <span style="color: #008000; font-weight: bold;">value</span><br />
&nbsp; &nbsp;new <span style="color: #008000; font-weight: bold;">type</span> Account::Name<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;Mr Johnson&quot;</span><span style="color: #339933;">&#41;</span>::<span style="color: #008000; font-weight: bold;">Address</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;Somewhere, some place&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; ::Telephone<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;+44 1234 4321&quot;</span><span style="color: #339933;">&#41;</span><span style="color: #000066;">.</span><br />
01 sAccount <span style="color: #008000; font-weight: bold;">type</span> Account <span style="color: #008000; font-weight: bold;">value</span><br />
&nbsp; &nbsp;new <span style="color: #008000; font-weight: bold;">type</span> Account::Name<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;Mr Smith&quot;</span><span style="color: #339933;">&#41;</span>::<span style="color: #008000; font-weight: bold;">Address</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;Nowhere place&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp;::Telephone<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;+44 1234 4321&quot;</span><span style="color: #339933;">&#41;</span>::Country<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;Wales&quot;</span><span style="color: #339933;">&#41;</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
01 lAccount <span style="color: #008000; font-weight: bold;">type</span> Account<span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> accounts::<span style="color: #000000; font-weight: bold;">Add</span><span style="color: #339933;">&#40;</span>jAccount<span style="color: #339933;">&#41;</span><br />
&nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> accounts::<span style="color: #000000; font-weight: bold;">Add</span><span style="color: #339933;">&#40;</span>sAccount<span style="color: #339933;">&#41;</span><br />
&nbsp;<br />
&nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> lAccount <span style="color: #008000; font-weight: bold;">through</span> accounts<br />
&nbsp; <span style="color: #000000; font-weight: bold;">display</span> lAccount<br />
&nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span><br />
<br />
&nbsp;<span style="color: #000000; font-weight: bold;">goback</span><span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">program</span><span style="color: #000066;">.</span></div></div>
<p>WIth the class being:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000; font-weight: bold;">class-id</span> Account<span style="color: #000066;">.</span><br />
<br />
<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
01 wName &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">string</span> property <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Name&quot;</span><span style="color: #000066;">.</span><br />
01 wAddres &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">string</span> property <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Address&quot;</span><span style="color: #000066;">.</span><br />
01 wCountry &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">string</span> property <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Country&quot;</span><span style="color: #000066;">.</span><br />
01 wTelephone &nbsp;<span style="color: #008000; font-weight: bold;">string</span> property <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Telephone&quot;</span><span style="color: #000066;">.</span><br />
01 wEmail &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">string</span> property <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Email&quot;</span><span style="color: #000066;">.</span><br />
<br />
<span style="color: #008000; font-weight: bold;">method-id</span> New<span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> wCountry <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">type</span> System<span style="color: #000066;">.</span>Globalization<span style="color: #000066;">.</span>RegionInfo::CurrentRegion::DisplayName<br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span><br />
<br />
<span style="color: #008000; font-weight: bold;">method-id</span> Name public<span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> uName <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">string</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ret <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">type</span> Account<span style="color: #000066;">.</span><br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> self::Name <span style="color: #000000; font-weight: bold;">to</span> uName<br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> ret <span style="color: #000000; font-weight: bold;">to</span> self<br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span><br />
<br />
<span style="color: #008000; font-weight: bold;">method-id</span> <span style="color: #008000; font-weight: bold;">Address</span> public<span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> uAddress <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">string</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ret <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">type</span> Account<span style="color: #000066;">.</span><br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> self::<span style="color: #008000; font-weight: bold;">Address</span> <span style="color: #000000; font-weight: bold;">to</span> uAddress<br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> ret <span style="color: #000000; font-weight: bold;">to</span> self<br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span><br />
<br />
<span style="color: #008000; font-weight: bold;">method-id</span> Telephone public<span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> uTelephone <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">string</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ret <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">type</span> Account<span style="color: #000066;">.</span><br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> self::<span style="color: #008000; font-weight: bold;">Address</span> <span style="color: #000000; font-weight: bold;">to</span> uTelephone<br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> ret <span style="color: #000000; font-weight: bold;">to</span> self<br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span><br />
<br />
<span style="color: #008000; font-weight: bold;">method-id</span> Email public<span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> uEmail <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">string</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ret <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">type</span> Account<span style="color: #000066;">.</span><br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> self::<span style="color: #008000; font-weight: bold;">Address</span> <span style="color: #000000; font-weight: bold;">to</span> uEmail<br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> ret <span style="color: #000000; font-weight: bold;">to</span> self<br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span><br />
<br />
<span style="color: #008000; font-weight: bold;">method-id</span> Country public<span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> uCountry <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">string</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ret <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">type</span> Account<span style="color: #000066;">.</span><br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> self::Country <span style="color: #000000; font-weight: bold;">to</span> uCountry<br />
&nbsp; <span style="color: #008000; font-weight: bold;">set</span> ret <span style="color: #000000; font-weight: bold;">to</span> self<br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span><br />
<br />
<span style="color: #008000; font-weight: bold;">method-id</span> ToString public override<span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #000000; font-weight: bold;">returning</span> ret <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">string</span><span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">set</span> ret <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">String</span>::Format<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;Name:{0}, Address:{1}, Telephone:{2}, Email:{3}, Country:{4}&quot;</span><span style="color: #000066;">,</span> <br />
&nbsp; &nbsp; &nbsp;self::Name<span style="color: #000066;">,</span> self::<span style="color: #008000; font-weight: bold;">Address</span><span style="color: #000066;">,</span> self::Telephone<span style="color: #000066;">,</span><br />
&nbsp; &nbsp; &nbsp;self::Email<span style="color: #000066;">,</span> self::Country<span style="color: #339933;">&#41;</span><br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">class</span><span style="color: #000066;">.</span></div></div>
<p>Which when run with Visual COBOL gives: </p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Name:Mr Johnson, Address:+44 1234 4321, Telephone:, Email:, Country:United Kingdom<br />
Name:Mr Smith, Address:+44 1234 4321, Telephone:, Email:, Country:Wales</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2010/05/method-chaining/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Life under the dust cloud</title>
		<link>http://www.gennard.net/blog/2010/04/life-under-the-dust-cloud/</link>
		<comments>http://www.gennard.net/blog/2010/04/life-under-the-dust-cloud/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 07:20:16 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[India]]></category>
		<category><![CDATA[TechEd]]></category>
		<category><![CDATA[cobolator]]></category>
		<category><![CDATA[Microsoft india 2010]]></category>
		<category><![CDATA[palaces]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=585</guid>
		<description><![CDATA[The week before last I attended Microsoft TechEd here in India, which was a great success. I especially liked my boss &#8220;The COBOLATOR&#8220;, who did a great talk about his experiences with Microsoft and his views on using COBOL. This combined we another great talk by Paul/PaulA and Mark about how COBOL is everywhere and [...]]]></description>
			<content:encoded><![CDATA[<p>The week before last I attended Microsoft TechEd here in India, which was a great success.</p>
<p> I especially liked my boss &#8220;The <a href="http://www.cobol.se/Cobolator.html">COBOLATOR</a>&#8220;, who did a great talk about his experiences with Microsoft and his views on using COBOL.   This combined we another great talk by Paul/PaulA and Mark about how COBOL is everywhere and how Visual COBOL can seriously help you take advantage of existing COBOL code as well as showing how great COBOL is for new development made a great conference.</p>
<p>When I was not seeing my colleagues perform on stage, I was at our stand meeting people and I have to say the people at the conference were amazingly friendly and very happy to talk mere developer such as myself.   It was honestly refreshing to meet such open minded people with a honest interest in using Microsoft technology to its fullest.</p>
<p>Well that was then and now; me and several of my colleagues are trying to get home to the UK but due to the dust cloud caused by the Icelandic volcano we are stranded here.   However rather than going completely insane, we have tried to keep busy doing some work and visiting some local sites.</p>
<p>To that end, I have placed some of my photo’s from, these can be found [<a href="http://cid-cf721f64506e6226.skydrive.live.com/browse.aspx/.Public/India/India%20-%20Bangalore/Gardens%20and%20Palaces">Here</a>]. </p>
<p>I hope you find them interesting and thank goodness for the SkyDrive in the cloud <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2010/04/life-under-the-dust-cloud/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Visual COBOL @ Microsoft Teched</title>
		<link>http://www.gennard.net/blog/2010/03/visual-cobol-teched/</link>
		<comments>http://www.gennard.net/blog/2010/03/visual-cobol-teched/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 21:23:17 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[TechEd]]></category>
		<category><![CDATA[cobol.net]]></category>
		<category><![CDATA[micro focus cobol]]></category>
		<category><![CDATA[Microsoft india 2010]]></category>
		<category><![CDATA[microsoft teched india]]></category>
		<category><![CDATA[microsoft teched india 2010]]></category>
		<category><![CDATA[microsoft teched las vegas]]></category>
		<category><![CDATA[Visual COBOL]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=557</guid>
		<description><![CDATA[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&#8217;s my excuse.. Well we have been counting down the internal builds of Visual COBOL and we are pretty much ready to [...]]]></description>
			<content:encoded><![CDATA[<p>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..</p>
<p>So, what&#8217;s my excuse.. Well we have been counting down the internal builds of <a href="http://vs2010.microfocus.com/visual-cobol.html">Visual COBOL</a> and we are pretty much ready to ship which is a relief since we are going to launching it at the <i>Microsoft’s Visual Studio launch parties in Las Vegas and TechEd in Bangalore April 12-14</i>.</p>
<p>Personally for me I am quite excited because I will be going to Teched in Bangalore to help show off Visual COBOL.</p>
<p>If would like a look at some of the Visual Studio 2010 integration Micro Focus has is about to release, pop along to <a href="http://www.microsoftteched.in/">http://vs2010.microfocus.com/</a> and see for yourself.   Better still, have a visit to teched <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I will finish the silly little blog with a link to a demo of Visual COBOL.  Just because I&#8217;m proud of it&#8230;</p>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/-1Pi0rxjk3Y&#038;hl=en_US&#038;fs=1&#038;color1=0x3a3a3a&#038;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-1Pi0rxjk3Y&#038;hl=en_US&#038;fs=1&#038;color1=0x3a3a3a&#038;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>ref: <a href="http://www.microsoftteched.in/">http://www.microsoftteched.in/</a><br />
 and <a href="http://www.microsoft.com/visualstudio/en-gb/products/2010/default.mspx">http://www.microsoft.com/visualstudio/en-gb/products/2010/default.mspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2010/03/visual-cobol-teched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reflection and COBOL</title>
		<link>http://www.gennard.net/blog/2010/02/cobol-dotnet-reflection/</link>
		<comments>http://www.gennard.net/blog/2010/02/cobol-dotnet-reflection/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 22:56:01 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[cobol.net]]></category>
		<category><![CDATA[managed cobol]]></category>
		<category><![CDATA[reflection]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=525</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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&#8230; and here it is.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #a0a0a0; font-style: italic;">$set ilusing&quot;System.Reflection&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; 01 myAssembly <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Assembly&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; 01 usedAssemblyName <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;AssemblyName&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> myAssembly <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Assembly&quot;</span>::<span style="color: #ff0000;">&quot;GetExecutingAssembly&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;My exe is &quot;</span> myAssembly::<span style="color: #ff0000;">&quot;FullName&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;and is using CLR &quot;</span> myAssembly::<span style="color: #ff0000;">&quot;ImageRuntimeVersion&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;and is loaded from &quot;</span> myAssembly::<span style="color: #ff0000;">&quot;Location&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;the initial method of this program was &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myAssembly::<span style="color: #ff0000;">&quot;EntryPoint&quot;</span>::<span style="color: #ff0000;">&quot;Name&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;This assembly references -&gt; &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> usedAssemblyName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">through</span> myAssembly::<span style="color: #ff0000;">&quot;GetReferencedAssemblies&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;-&gt; &quot;</span> usedAssemblyName<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">end-perform</span></div></div>
<p>And the output of the program is: </p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">My exe is clrver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null<br />
and is using CLR v2.0.50727<br />
and is loaded from d:\clrver.exe<br />
the initial method of this program was _MF_ENTRYThis assembly references -&gt; <br />
-&gt; mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089<br />
-&gt; MicroFocus.COBOL.Runtime, Version=3.6.0.0, Culture=neutral, <br />
PublicKeyToken=0412c5e0b2aaa8f0</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2010/02/cobol-dotnet-reflection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting Languages and COBOL</title>
		<link>http://www.gennard.net/blog/2010/01/scripting-languages-and-cobol/</link>
		<comments>http://www.gennard.net/blog/2010/01/scripting-languages-and-cobol/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 10:39:04 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javax.script]]></category>
		<category><![CDATA[JSR 223]]></category>
		<category><![CDATA[Micro Focus]]></category>
		<category><![CDATA[Net Express]]></category>
		<category><![CDATA[ScriptEngine]]></category>
		<category><![CDATA[ScriptEngineManager]]></category>
		<category><![CDATA[ScriptObject]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=462</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>Interoperability between languages is very important to COBOL environments just as much as other languages.   Some platforms such as Microsoft&#8217;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.</p>
<p>Environments such as Sun&#8217;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.</p>
<p>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.</p>
<p>This mechanism is very simple to use, you just need to let our object COBOL runtime know the class is a Java class, which can be done by placing $JAVA$ before the name of the class and ensuring the class itself can be found by the JVM itself usually by adding an extra directories or .jar files to the CLASSPATH environment variable.</p>
<p>With Java 6.0 and JSR 223 support for Java based scripting languages were provided via the package javax.script.</p>
<p>Java has a wealth of scripting languages from awk to xlst.  My favourites being <a href="http://jython.sourceforge.net/">jpython</a>, <a href="http://jruby.sourceforge.net/">jruby</a> and <a href="http://www.mozilla.org/rhino">javascript</a>.</p>
<p>The java.net website has a comprehensive list of scripting languages -<br />
<a href="https://scripting.dev.java.net/">https://scripting.dev.java.net/</a>.</p>
<p>To use the scripting packages, you first need to create a ScriptEngineManager, then use this to create a specific ScriptEngine object for your chosen scripting language and use it.</p>
<p>For example:</p>
<li>Create a ScriptEngineManager object.</li>
<li>Retrieve a ScriptEngine object from the manager.</li>
<li>Evaluate a script using the ScriptEngine object.</li>
<p>In COBOL this is quite simply: </p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="">*&gt; ooctrl(+p) required for COM and Java classes</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; ooctrl(-f) used to preserve case of method names for Java</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ooctrl(+p) ooctrl(-f)</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-control</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-Script-EngineManager <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$javax.script.ScriptEngineManager&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-Script-Engine <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$javax.script.ScriptEngine&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.lang.Object&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-System <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.lang.System&quot;</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-PrintStream <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.io.PrintStream&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-obj-sem &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Script-EngineManager<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-javascript &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Script-Engine<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-obj &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-pout &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-PrintStream<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> cls-Script-EngineManager <span style="color: #ff0000;">&quot;new&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-obj-sem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-obj-sem <span style="color: #ff0000;">&quot;getEngineByName&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;JavaScript&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-javascript <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;eval&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;z<span style="color: #ff0000;">&quot;print('Hello, world!')&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-obj<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-obj <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> cls-System <span style="color: #ff0000;">&quot;getout&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-pout<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-pout <span style="color: #ff0000;">&quot;println&quot;</span> &nbsp; <span style="color: #008000; font-weight: bold;">using</span> ws-obj<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-pout <span style="color: #ff0000;">&quot;finalize&quot;</span> &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-pout<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-obj <span style="color: #ff0000;">&quot;finalize&quot;</span> &nbsp; <span style="color: #000000; font-weight: bold;">returning</span> ws-obj<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
<br />
&nbsp; &nbsp; &nbsp; $if NO-FINALIZE <span style="color: #008000; font-weight: bold;">not</span> defined<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-obj-sem <span style="color: #ff0000;">&quot;finalize&quot;</span> &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-obj-sem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;finalize&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-javascript<br />
&nbsp; &nbsp; &nbsp; $end<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">stop</span> <span style="color: #008000; font-weight: bold;">run</span><span style="color: #000066;">.</span></div></div>
<p>The actual Javascript being execute is contained in the invoke statement, which is simply:</p>
<div class="codecolorer-container javascript blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hello, world!'</span><span style="color: #009900;">&#41;</span></div></div>
<p>To use the above example, we first need to compile the code and run it.. which is done as follows:</p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\jscripting\HelloWorld&gt;cobol cbljscript.cbl int(); <br />
Micro Focus Net Express V5<br />
Version 6.0.00059 &nbsp;Copyright (C) 1984-2009 Micro Focus (IP) Limited.<br />
URN AXCGG/AA0/00000 <br />
* Checking complete with no errors - starting code generation<br />
* Generating cbljscript<br />
* Data: &nbsp; &nbsp; &nbsp; &nbsp; 848 &nbsp; &nbsp; Code: &nbsp; &nbsp; &nbsp; &nbsp;1992 &nbsp; &nbsp; Literals: &nbsp; &nbsp; &nbsp; &nbsp; 904<br />
<br />
C:\jscripting\HelloWorld&gt;runm cbljscript <br />
Micro Focus Net Express V6.0.00059 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
RUN TIME ENVIRONMENT Copyright (C) 1984-2009 Micro Focus (IP) Limited. &nbsp; &nbsp; &nbsp; &nbsp; <br />
URN AXCGG/AA0/00000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
Hello, world!</div></div>
</p>
<p>This is just the start, the next thing piece that is required with interoperability to another language is the ability to pass parameters to in and out of the script.  Luckily for us the clever chaps on the jsr group have provided &#8216;put&#8217; and &#8216;get&#8217; methods that allows us to simply put a name parameter and get the resulting updated or new parameter.</p>
<p>So consider the example, where we need to setup a parameter called &#8216;message&#8217; for the script and then read a parameter called &#8216;replyMessage&#8217; after the script has been executed.   The javascript to do this is: </p>
<div class="codecolorer-container javascript blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/* Do some insanity checking! */</span><br />
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; message <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;ERROR - 'message' has not been setup&quot;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
println<span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><br />
<br />
replyMessage <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Hello from javascript&quot;</span></div></div>
<p>To setup the message parameter, we just need todo.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; Put a variable in engine, so the javascript</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; can use it.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;put&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;z<span style="color: #ff0000;">&quot;message&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;z<span style="color: #ff0000;">&quot;Hello World from COBOL!&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">end-invoke</span></div></div>
<p>The after the script has executed, we just need to use the &#8216;get&#8217; method..</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; get a variable in engine</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;get&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;z<span style="color: #ff0000;">&quot;replyMessage&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-<span style="color: #008000; font-weight: bold;">message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">end-invoke</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; now display the replyMessage if it is available</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">if</span> ws-<span style="color: #008000; font-weight: bold;">message</span> <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-pout <span style="color: #ff0000;">&quot;println&quot;</span> &nbsp; <span style="color: #008000; font-weight: bold;">using</span> ws-<span style="color: #008000; font-weight: bold;">message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Javascript did not set a replyMessage var&quot;</span></div></div>
<p>The completed COBOL example below, uses a side file for the javascript too, the code is as follows:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="">*&gt; ooctrl(+p) required for COM and Java classes</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; ooctrl(-f) used to preserve case of method names for Java</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ooctrl(+p) ooctrl(-f)</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-control</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-Script-EngineManager <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$javax.script.ScriptEngineManager&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-Script-Engine <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$javax.script.ScriptEngine&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.lang.Object&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-System <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.lang.System&quot;</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-PrintStream <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.io.PrintStream&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-FileReader <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.io.FileReader&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-<span style="color: #008000; font-weight: bold;">file</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-FileReader<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-obj-sem &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Script-EngineManager<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-javascript &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Script-Engine<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-obj &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-<span style="color: #008000; font-weight: bold;">message</span> &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-pout &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-PrintStream<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; setup ws-pout to be System.out object</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> cls-System <span style="color: #ff0000;">&quot;getout&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-pout<br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; Setup a FileReader object for the external helloworld.js file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> cls-FileReader <span style="color: #ff0000;">&quot;new&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z<span style="color: #ff0000;">&quot;helloworld.js&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">returning</span> ws-<span style="color: #008000; font-weight: bold;">file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; Create a new script manager</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> cls-Script-EngineManager <span style="color: #ff0000;">&quot;new&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-obj-sem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; Find the javascript engine</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-obj-sem <span style="color: #ff0000;">&quot;getEngineByName&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;JavaScript&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-javascript <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; Put a variable in engine, so the javascript</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; can use it.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;put&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z<span style="color: #ff0000;">&quot;message&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z<span style="color: #ff0000;">&quot;Hello World from COBOL!&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; do some javascript stuff!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;eval&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ws-<span style="color: #008000; font-weight: bold;">file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">returning</span> ws-obj-sem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; get a variable in engine</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;get&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z<span style="color: #ff0000;">&quot;replyMessage&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">returning</span> ws-<span style="color: #008000; font-weight: bold;">message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; now display the replyMessage if it is available</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-<span style="color: #008000; font-weight: bold;">message</span> <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-pout <span style="color: #ff0000;">&quot;println&quot;</span> &nbsp; <span style="color: #008000; font-weight: bold;">using</span> ws-<span style="color: #008000; font-weight: bold;">message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Javascript did not set a replyMessage var&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; cleanup code, not strickly needed for the example but</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; its good practice, to do it.</span><br />
&nbsp; &nbsp; &nbsp; $if NO-FINALIZE <span style="color: #008000; font-weight: bold;">not</span> defined<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-<span style="color: #008000; font-weight: bold;">message</span> <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-<span style="color: #008000; font-weight: bold;">message</span> <span style="color: #ff0000;">&quot;finalize&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-<span style="color: #008000; font-weight: bold;">message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-pout <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-pout <span style="color: #ff0000;">&quot;finalize&quot;</span> &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-pout<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-obj-sem <span style="color: #ff0000;">&quot;finalize&quot;</span> &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-obj-sem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;finalize&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-javascript<br />
&nbsp; &nbsp; &nbsp; $end<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">stop</span> <span style="color: #008000; font-weight: bold;">run</span><span style="color: #000066;">.</span></div></div>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\jscripting\HelloWorld3&gt;cobol cbljscript.cbl int(); <br />
Micro Focus Net Express V5<br />
Version 6.0.00059 &nbsp;Copyright (C) 1984-2009 Micro Focus (IP) Limited.<br />
URN AXCGG/AA0/00000 <br />
* Checking complete with no errors - starting code generation<br />
* Generating cbljscript<br />
* Data: &nbsp; &nbsp; &nbsp; &nbsp; 888 &nbsp; &nbsp; Code: &nbsp; &nbsp; &nbsp; &nbsp;2528 &nbsp; &nbsp; Literals: &nbsp; &nbsp; &nbsp; &nbsp;1296<br />
<br />
C:\jscripting\HelloWorld3&gt;runm cbljscript <br />
Micro Focus Net Express V6.0.00059 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
RUN TIME ENVIRONMENT Copyright (C) 1984-2009 Micro Focus (IP) Limited. &nbsp; &nbsp; &nbsp; &nbsp; <br />
URN AXCGG/AA0/00000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
Hello World from COBOL!<br />
Hello from javascript</div></div>
<p>As you can see from the code above, setting up parameter is pretty easy todo but sometimes we just want to execute a function in the scripting language such as:</p>
<div class="codecolorer-container javascript blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> testMessage<span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;testMessage : &quot;</span> <span style="color: #339933;">+</span> msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>The ScriptEngine object that we have created to use the scripting engine may implement an optional interface called javax.script.Invocable, if the scripting engine we are using does provide this interface then a method called invokeFunction(..) can be used.</p>
<p>In order to reduce the size of the COBOL code, I have coded a simple utils class in java as a simple proxy layer, the code is pretty simple but does make it easier for the COBOL to use the invokeFunction() method.</p>
<div class="codecolorer-container javascript blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Then from the COBOL side<span style="color: #339933;">,</span> we can just <span style="color: #003366; font-weight: bold;">use</span> the invokeFunction above.<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>For example<span style="color: #339933;">:&lt;/</span>p<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>code lang<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;cobol&quot;</span> width<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;800&quot;</span> lines<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;-1&quot;</span> nowrap<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #339933;">*&gt;</span> invoke a <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #000066; font-weight: bold;">with</span> one parameter<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invoke cls<span style="color: #339933;">-</span>utils <span style="color: #3366CC;">&quot;invokeFunction&quot;</span> using<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ws<span style="color: #339933;">-</span>javascript<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;z<span style="color: #3366CC;">&quot;testMessage&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;z<span style="color: #3366CC;">&quot;Hello to function testMessage from COBOL&quot;</span></div></div>
<p>Which gives us the following output when executed.</p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\jscripting\InvokeFunction&gt;runm cbljscript<br />
Micro Focus Net Express V6.0.00059<br />
RUN TIME ENVIRONMENT Copyright (C) 1984-2009 Micro Focus (IP) Limited.<br />
URN AXCGG/AA0/00000<br />
<br />
testMessage : Hello to function testMessage from COBOL</div></div>
<p>The completed example is as follows:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="">*&gt; ooctrl(+p) required for COM and Java classes</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; ooctrl(-f) used to preserve case of method names for Java</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ooctrl(+p) ooctrl(-f)</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-control</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-Script-EngineManager <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$javax.script.ScriptEngineManager&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-Script-Engine <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$javax.script.ScriptEngine&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.lang.Object&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-System <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.lang.System&quot;</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-PrintStream <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.io.PrintStream&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-FileReader <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$java.io.FileReader&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cls-Utils <span style="color: #008000; font-weight: bold;">is</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;$JAVA$utils&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-<span style="color: #008000; font-weight: bold;">file</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-FileReader<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-obj-sem &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Script-EngineManager<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-javascript &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Script-Engine<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-<span style="color: #008000; font-weight: bold;">message</span> &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 ws-pout &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-PrintStream<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; setup ws-pout to be System.out object</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> cls-System <span style="color: #ff0000;">&quot;getout&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-pout<br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; Setup a FileReader object for the external helloworld.js file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> cls-FileReader <span style="color: #ff0000;">&quot;new&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z<span style="color: #ff0000;">&quot;helloworld.js&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">returning</span> ws-<span style="color: #008000; font-weight: bold;">file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; Create a new script manager</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> cls-Script-EngineManager <span style="color: #ff0000;">&quot;new&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-obj-sem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; Find the javascript engine</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-obj-sem <span style="color: #ff0000;">&quot;getEngineByName&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;JavaScript&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-javascript <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; do some javascript function</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;eval&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ws-<span style="color: #008000; font-weight: bold;">file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">returning</span> ws-obj-sem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; invoke a function with one parameter</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> cls-utils <span style="color: #ff0000;">&quot;invokeFunction&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ws-javascript<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z<span style="color: #ff0000;">&quot;testMessage&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z<span style="color: #ff0000;">&quot;Hello to function testMessage from COBOL&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">returning</span> ws-<span style="color: #008000; font-weight: bold;">message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; cleanup code, not strickly needed for the example but</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; its good practice, to do it.</span><br />
&nbsp; &nbsp; &nbsp; $if NO-FINALIZE <span style="color: #008000; font-weight: bold;">not</span> defined<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-<span style="color: #008000; font-weight: bold;">file</span> <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-<span style="color: #008000; font-weight: bold;">file</span> <span style="color: #ff0000;">&quot;finalize&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-<span style="color: #008000; font-weight: bold;">file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-<span style="color: #008000; font-weight: bold;">message</span> <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-<span style="color: #008000; font-weight: bold;">message</span> <span style="color: #ff0000;">&quot;finalize&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-<span style="color: #008000; font-weight: bold;">message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-pout <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-pout <span style="color: #ff0000;">&quot;finalize&quot;</span> &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-pout<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-obj-sem <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-obj-sem <span style="color: #ff0000;">&quot;finalize&quot;</span> &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> ws-obj-sem<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> ws-javascript <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> ws-javascript <span style="color: #ff0000;">&quot;finalize&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> ws-javascript<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; $end<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">stop</span> <span style="color: #008000; font-weight: bold;">run</span><span style="color: #000066;">.</span></div></div>
<p>Conclusions: Using a Java based scripting language from COBOL is quite easy, so feel free to use it.   Now which scripting language should I use&#8230;?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2010/01/scripting-languages-and-cobol/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>12 Tips for using Micro Focus COBOL</title>
		<link>http://www.gennard.net/blog/2009/12/12-cobol-tips/</link>
		<comments>http://www.gennard.net/blog/2009/12/12-cobol-tips/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 22:36:33 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=396</guid>
		<description><![CDATA[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&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<h1>12 Tips for using Micro Focus COBOL</h1>
<p>As it is close to Christmas and I wanted to do something with <b>12</b> in the title, I&#8217;ve thrown together some useful if not un-ordered list of 12 things tips using Micro Focus COBOL.</p>
<p>Remember I am just a developer and just want to help fellow developers out <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   so&#8230;</p>
<h2>Merry Christmas!</h2>
<p>and here is my list&#8230;</p>
<ol>
<li>Use DLLs/Shared objects rather than .int code</li>
<li>DLLs/Shared objects can be preloaded using:
<div class="codecolorer-container cobol blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">01 my-ptr procedure-<span style="color: #008000; font-weight: bold;">pointer</span><span style="color: #000066;">.</span><br />
<span style="color: #008000; font-weight: bold;">set</span> my-ptr <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">entry</span> <span style="color: #ff0000;">&quot;sodllname&quot;</span></div></div>
<p><b>Note; sodllname does not have the extension&#8230; let the runtime choose it for you!</b>
</li>
<li>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.</li>
<li>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&#8230;)</li>
<li>Try using managed code (.Net) if you want to create <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation">WPF</a>/<a href="http://en.wikipedia.org/wiki/Windows_Forms">WinForms </a>or use <a href="http://en.wikipedia.org/wiki/Windows_Communication_Foundation">WCF</a></li>
<li>Interopability is great, so if you see a <a href="http://supportline.microfocus.com/Documentation/books/nx40/dijaco.htm">Java Class</a>,<a href="http://supportline.microfocus.com/documentation/books/nx60/lhcpro.htm"> .Net Class, </a><a href="http://supportline.microfocus.com/documentation/books/nx50ws03/dmcwiz.htm">COM object</a>, <a href="http://supportline.microfocus.com/documentation/books/sx40/printf.htm">&#8216;C&#8217; function</a> or a Web Service&#8230; use it!  You can even mix unmanaged and managed applications..</li>
<li>Avoid using the following if performance is key, as this really does help our code generator:
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">alter<br />
perform thru <br />
next sentence <br />
segments <br />
go to section-name <br />
go to paragraph outside the current section</div></div>
</li>
<li>Try to end your routine with a &#8220;stop run [returning..]&#8221; or &#8220;exit program [returning..]&#8221; or &#8220;goback [returning..]&#8221; as this gives our code generators a defined end to the routine, which really does help our code analysis/generator</li>
<li>Use comp-5, integers for speed in calculations or native .Net types in managed</li>
<li>Use comp-x for portability (file formats etc..)</li>
<li>Make your application more robust, use tracing in production systems, either our own CTF tracing or your own or third party&#8230; it will save your life one day! Use runtime routines to catch error and log them (<a href="http://supportline.microfocus.com/documentation/books/sx40/prcblr.htm">CBL_ERROR_PROC</a>), ensure your programs shutdown cleanly always use <a href="http://supportline.microfocus.com/documentation/books/sx40/prcblr.htm">CBL_EXIT_PROC</a>.</li>
<li>Use the generator directive <i>nocheck</i> if you are happy your code is solid and want to a little more performance. ie: it turns off runtime bounds checking</li>
</ol>
<p>Further reading: </p>
<li><a href="http://www.microfocus.com/000/20030701_008_tcm21-6189.pdf">Coding for speed, size and portability</a></li>
<li><a href="http://www.microfocus.com/000/Cobol-for-Eclipse-v2_FINAL_tcm21-23611.pdf">Eclipse/COBOL on Unix</a></li>
<li><a href=http://www.microfocus.com/000/20050901-003a_tcm21-6055.pdf">Newsletter about CTF</a></li>
<li>For CTF_ APIs see CBL_CTF_ see <a href="http://supportline.microfocus.com/documentation/books/nx50ws03/rhcall17.htm">library routines</a></li>
<p>Yes.. its a bit of a mixed list.. but hey it may be of help!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/12/12-cobol-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Comparison Of .Net COBOL, Visual Basic and C#</title>
		<link>http://www.gennard.net/blog/2009/12/cobol-vb-csharp-compared/</link>
		<comments>http://www.gennard.net/blog/2009/12/cobol-vb-csharp-compared/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 12:35:44 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[cobol.net]]></category>
		<category><![CDATA[vb]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=382</guid>
		<description><![CDATA[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 &#8220;real&#8221; article itself. Enjoy. Alex Turner said: A [...]]]></description>
			<content:encoded><![CDATA[<p>Today my collegues Robert and Alex have finally <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  decided to publish a document that compares Visual Basic, C# and COBOL for .Net under <a href="http://creativecommons.org/licenses/by-sa/2.5/">The Creative Commons Attribution-ShareAlike 2.5 License</a>.</p>
<p>Rather than doing a cut-paste job, here is a quote from alex, along with a link to the &#8220;real&#8221; article itself.</p>
<p>Enjoy.</p>
<blockquote>
<p>Alex Turner said:</p>
<p><strong><em>A Comparison Of .Net COBOL, Visual Basic and C#</em></strong></p>
<p><strong>Introduction</strong></p>
<p>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. </p>
<p><strong>Background</strong></p>
<p>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.</p>
<p>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&#8217; attention and to help people who need to work with COBOL on the .net platform.</p>
<p><a href="http://www.codeproject.com/KB/net-languages/COBOLvsVBvsCSharp.aspx">Click here to continue reading the rest of the article&#8230;</a></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/12/cobol-vb-csharp-compared/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free compiler for non-commercial use.</title>
		<link>http://www.gennard.net/blog/2009/12/free-compiler-for-non-commercial-use/</link>
		<comments>http://www.gennard.net/blog/2009/12/free-compiler-for-non-commercial-use/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 08:38:25 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[cobol.net]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[non-commercial]]></category>
		<category><![CDATA[visualstudio]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=372</guid>
		<description><![CDATA[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 &#8220;]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<blockquote><p>From: Twitter &#8220;<a href="http://twitter.com/scotnielsen/"scot nielsen">Scot Nielsen</a> said: Micro Focus COBOL for .NET and Visual Studio available here FREE for non-commercial.
</p></blockquote>
<p>The development environment/compiler can be downloaded from the <a href="http://www.microfocus.com/Resources/Communities/Academic/shop/">Micro Focus Shop</a>.</p>
<p>More information can be picked up from the <a href="http://visualstudiogallery.msdn.microsoft.com/de-de/326d29fe-24b6-43ee-b453-bfe9572ce10b">Microsoft Visual Studio Gallery</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/12/free-compiler-for-non-commercial-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Factory Method Pattern in COBOL</title>
		<link>http://www.gennard.net/blog/2009/12/factory-method-pattern-in-cobol/</link>
		<comments>http://www.gennard.net/blog/2009/12/factory-method-pattern-in-cobol/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 20:49:24 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[cobol.net]]></category>
		<category><![CDATA[factorypattern]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=363</guid>
		<description><![CDATA[Continuing my series on design patterns for the COBOL, the next one on my list is the &#8220;Factory method&#8221; pattern. The pattern is useful, as it helps you hide the real implementation/creation mechanism of your classes. I you are fond of uml&#8230; here is the actual uml (from wikipedia). Factory Method Pattern from Wikipedia! So&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing my series on design patterns for the COBOL, the next one on my list is the &#8220;Factory method&#8221; pattern.</p>
<p>The pattern is useful, as it helps you hide the real implementation/creation mechanism of your classes.   I you are fond of uml&#8230; here is the actual uml (from wikipedia).</p>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/FactoryMethod.svg/500px-FactoryMethod.svg.png" /></p>
<p><a href="http://en.wikipedia.org/wiki/Factory_method_pattern">Factory Method Pattern</a> from Wikipedia!</p>
<p>So&#8230; lets see the COBOL code&#8230;</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;interface-id<span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;Base&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;DoIt&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;DoIt&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> interface <span style="color: #ff0000;">&quot;Base&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;Derived1Impl&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span> implements <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Base&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;DoIt&quot;</span> public<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Derived1Impl from DoIt&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;DoIt&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;Derived1Impl&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;Derived2Impl&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span> implements <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Base&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;DoIt&quot;</span> public<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Derived2Impl from DoIt&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;DoIt&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;Derived2Impl&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;Factory&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;GetObject&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;01 obj-base <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Base&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> oType <span style="color: #008000; font-weight: bold;">as</span> binary-long<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> obj-base<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">evaluate</span> oType<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">when</span> 1 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> obj-base <span style="color: #000000; font-weight: bold;">to</span> new <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Derived1Impl&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">when</span> 2 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> obj-base <span style="color: #000000; font-weight: bold;">to</span> new <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Derived2Impl&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">when</span> <span style="color: #008000; font-weight: bold;">other</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> obj-base <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;GetObject&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;Factory&quot;</span><span style="color: #000066;">.</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;FactoryDemo&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;Main&quot;</span> <span style="color: #008000; font-weight: bold;">static</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 obj-factory <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Factory&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 base-obj <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Base&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 args <span style="color: #008000; font-weight: bold;">string</span> <span style="color: #008000; font-weight: bold;">occurs</span> <span style="color: #008000; font-weight: bold;">any</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> args<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> obj-factory <span style="color: #000000; font-weight: bold;">to</span> new <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Factory&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> base-obj <span style="color: #000000; font-weight: bold;">to</span> obj-factory::<span style="color: #ff0000;">&quot;GetObject&quot;</span><span style="color: #339933;">&#40;</span>1<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> base-obj::<span style="color: #ff0000;">&quot;DoIt&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> base-obj <span style="color: #000000; font-weight: bold;">to</span> obj-factory::<span style="color: #ff0000;">&quot;GetObject&quot;</span><span style="color: #339933;">&#40;</span>2<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> base-obj::<span style="color: #ff0000;">&quot;DoIt&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;Main&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;FactoryDemo&quot;</span><span style="color: #000066;">.</span></div></div>
<p>That was pretty straight forward&#8230; not too much pain&#8230;</p>
<p>And finally the code produces&#8230;</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">d:\&gt; FactoryDemo.exe<br />
Derived1Impl from DoIt<br />
Derived2Impl from DoIt<br />
Hello world</div></div>
<p>Time to sign off for today.. but if you would like me to continue the series on code patterns or have a particular pattern you need&#8230; drop us a line!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/12/factory-method-pattern-in-cobol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design Patterns and COBOL</title>
		<link>http://www.gennard.net/blog/2009/11/design-patterns-and-cobol/</link>
		<comments>http://www.gennard.net/blog/2009/11/design-patterns-and-cobol/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 22:40:29 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[DesignPatterns]]></category>
		<category><![CDATA[Singleton]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=307</guid>
		<description><![CDATA[As part of my working life I happy to say I use COBOL and for better or worse it is here to stay. With this in mind it annoys me I here/see saying things such as COBOL is a old language that naturally prohibits you from using modern design patterns. rubbish I say&#8230; COBOL can [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my working life I happy to say I use COBOL and for better or worse it is here to stay.  With this in mind it annoys me I here/see saying things such as<br />
<blockquote>COBOL is a old language that naturally prohibits you from using modern design patterns.</p></blockquote>
<p>rubbish I say&#8230; COBOL can be used in good ways and bad ways.</p>
<p>I will try and show you that COBOL can be used in a good way&#8230; lets take the &#8220;<a href="http://en.wikipedia.org/wiki/Singleton_pattern">Singleton pattern</a>&#8220;, as the first example.</p>
<p>First.. lets start off my creating a singleton class in csharp&#8230; so here it is: </p>
<div class="codecolorer-container csharp blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Collections</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">sealed</span> <span style="color: #FF0000;">class</span> MySingleton <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">readonly</span> Hashtable sharedHashtable <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Hashtable<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Explicit static constructor to tell C# compiler</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// not to mark type as beforefieldinit</span><br />
&nbsp; &nbsp; <span style="color: #0600FF;">static</span> MySingleton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF;">private</span> MySingleton<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> Hashtable Singleton <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> sharedHashtable<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>Not too shabby.. but lets see what we can do in COBOL&#8230; </p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ilusing&quot;System.Collections&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> &nbsp;<span style="color: #ff0000;">&quot;MySingleton&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 shared-hashtable &nbsp;<span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Hashtable&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">static</span> property <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Singleton&quot;</span> <span style="color: #008000; font-weight: bold;">with</span> <span style="color: #008000; font-weight: bold;">no</span> <span style="color: #008000; font-weight: bold;">set</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;New&quot;</span> <span style="color: #008000; font-weight: bold;">static</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> shared-hashtable <span style="color: #000000; font-weight: bold;">to</span> new <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Hashtable&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;New&quot;</span><span style="color: #000066;">.</span></div></div>
<p>What&#8230; COBOL is smaller&#8230; that can&#8217;t be true&#8230; sorry but it is&#8230;</p>
<p>To complete the example&#8230; lets use it&#8230;
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="">*&gt; Add two items to the single hashtable</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;MySingleton&quot;</span>::<span style="color: #ff0000;">&quot;Singleton&quot;</span>::<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;Add&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;01234567&quot;</span><span style="color: #000066;">,</span><span style="color: #ff0000;">&quot;Ian&quot;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;MySingleton&quot;</span>::<span style="color: #ff0000;">&quot;Singleton&quot;</span>::<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;Add&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;987654321&quot;</span><span style="color: #000066;">,</span><span style="color: #ff0000;">&quot;Stephen&quot;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt; Now get one of the items of the singleton</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Account 01234567 - Contains: &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;MySingleton&quot;</span>::<span style="color: #ff0000;">&quot;Singleton&quot;</span>::<span style="color: #ff0000;">&quot;Item&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;01234567&quot;</span><span style="color: #339933;">&#41;</span></div></div>
<p>And I am sure some people&#8230; will say sure&#8230; this is really true&#8230; it is&#8230; here is it running.. </p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">c:\temp&gt; cobol MySingleton.cbl ilgen(sub);<br />
c:\temp&gt; cobol UseSingleton.cbl ilgen ilref&quot;MySingleton.dll&quot;;<br />
c:\temp&gt; UseSingleton.exe<br />
Account 01234567 - Contains: Ian<br />
c:\temp&gt; csc MySingleton.cs /target:library<br />
c:\temp&gt; UseSingleton.exe<br />
Account 01234567 - Contains: Ian</div></div>
<p>Now it seems to me that COBOL is being under rated&#8230; perhaps someone should shout about it! <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8227618096827072";
/* 468x15, created 11/23/09 */
google_ad_slot = "6592882116";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/design-patterns-and-cobol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Type Safety and COBOL</title>
		<link>http://www.gennard.net/blog/2009/11/type-safety-and-cobol/</link>
		<comments>http://www.gennard.net/blog/2009/11/type-safety-and-cobol/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 23:27:34 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[TypeSafety]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=263</guid>
		<description><![CDATA[Having read a recent bog about COBOL and type-safety, I though I would jot down some comments. ANS85 COBOL is naturally is type-unsafe due as every data item being part of one memory region (or storage area), because of this it can make is difficult to talk to type-safe language such as Java or the [...]]]></description>
			<content:encoded><![CDATA[<p>Having read a recent bog about COBOL and type-safety, I though I would jot down some comments.</p>
<p>ANS85 COBOL is naturally is type-unsafe due as every data item being part of one memory region (or storage area), because of this it can make is difficult to talk to type-safe language such as Java or the CLR.</p>
<p>However, just like any computer language it does not stay still.  Object oriented features were added to COBOL, at this point in time you we were given the verbs to create 100% type safe application.</p>
<p>The key to writing type safe code is the use OBJECT-REFERENCE will a TYPE and using them on in your methods and using the INVOKE verb.</p>
<p>For example:</p>
<div class="codecolorer-container cobol blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">IDENTIFICATION</span> <span style="color: #008000; font-weight: bold;">DIVISION</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PROGRAM-ID</span><span style="color: #000066;">.</span> &nbsp; <span style="color: #ff0000;">&quot;TypeSafeExample&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">ENVIRONMENT</span> <span style="color: #008000; font-weight: bold;">DIVISION</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">CONFIGURATION</span> <span style="color: #000080; font-weight: bold;">SECTION</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">REPOSITORY</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">CLASS</span> SYS-<span style="color: #008000; font-weight: bold;">STRING</span> <span style="color: #008000; font-weight: bold;">AS</span> <span style="color: #ff0000;">&quot;System.String&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">DATA</span> <span style="color: #008000; font-weight: bold;">DIVISION</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">WORKING-STORAGE</span> <span style="color: #000080; font-weight: bold;">SECTION</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 hello-world-<span style="color: #008000; font-weight: bold;">string</span> &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">OBJECT</span> <span style="color: #008000; font-weight: bold;">REFERENCE</span> SYS-<span style="color: #008000; font-weight: bold;">STRING</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PROCEDURE</span> <span style="color: #008000; font-weight: bold;">DIVISION</span><span style="color: #000066;">.</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">SET</span> hello-world-<span style="color: #008000; font-weight: bold;">string</span> <span style="color: #000000; font-weight: bold;">TO</span> <span style="color: #ff0000;">&quot;Hello World&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">DISPLAY</span> hello-world-<span style="color: #008000; font-weight: bold;">string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">STOP</span> <span style="color: #008000; font-weight: bold;">RUN</span><span style="color: #000066;">.</span></div></div>
<p>The use of COBOL pictures can still be used, however for easy interop with other type-safe languages you really have to stick to the right types for your target environment when exposing your COBOL program to the other languages, this means if you are creating classes, the method to be consumed by other languages should use standard types, for .Net/CLR applications the use of <a href="http://msdn.microsoft.com/en-us/library/12a7a7h3(VS.71).aspx">CLS-COMPLIANT</a> types is the right approach.  For JVM applications, keep to the &#8220;core&#8221; java.lang types.  </p>
<p>Keep to these simple rules and COBOL will happy interop with type-safe languages. <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8227618096827072";
/* 468x15, created 11/23/09 */
google_ad_slot = "6592882116";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/type-safety-and-cobol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Base Class Library, Arrays, Queues and Stacks</title>
		<link>http://www.gennard.net/blog/2009/11/base-class-library-arrays-queues-and-stacks/</link>
		<comments>http://www.gennard.net/blog/2009/11/base-class-library-arrays-queues-and-stacks/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 21:41:27 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[BaseCL]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=234</guid>
		<description><![CDATA[Continuing the series of blogs about COBOL and the .Net base class library&#8230; The .Net base class library has a wealth classes and an huge of amount of methods/properties. The .Net base class library has a key handy namespace that contains are the lovely classes, which is System.Collections. As you can see from the above [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series of blogs about COBOL and the .Net base class library&#8230;</p>
<p>The .Net base class library has a wealth classes and an huge of amount of methods/properties. </p>
<p>The .Net base class library has a key handy namespace that contains are the lovely classes, which is <a href="http://msdn.microsoft.com/en-us/library/system.collections.aspx">System.Collections</a>.</p>
<p>As you can see from the above link, it does have quite a lot, so for this blob entry I will look at: </p>
<li>arrays of numbers</li>
<li>queues</li>
<li>stacks</li>
<p>Lets start the first example by using an array of numbers&#8230; just to demonstrate its not just strings you can assign to the arrays using &#8220;values&#8221;.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;01 numbers &nbsp;binary-long <span style="color: #008000; font-weight: bold;">occurs</span> 10<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">values</span> 10 20 30 40 50 10 20 30 40 50<span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 num &nbsp; &nbsp; &nbsp; binary-long <span style="color: #008000; font-weight: bold;">value</span> 0<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 average &nbsp; binary-double <span style="color: #008000; font-weight: bold;">value</span> 0<span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> num <span style="color: #008000; font-weight: bold;">through</span> numbers<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">add</span> num <span style="color: #000000; font-weight: bold;">to</span> average<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">end-perform</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">divide</span> average <span style="color: #008000; font-weight: bold;">by</span> numbers::<span style="color: #ff0000;">&quot;Length&quot;</span> <span style="color: #000000; font-weight: bold;">giving</span> average<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Average is : &quot;</span> average</div></div>
<p>Running the above code gives us:</p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Average is : +00000000000000000030</div></div>
<p>The next class that is helpful, is the Queue class, this allows us to &#8220;Enqueue&#8221; and &#8220;Dequeue&#8221; item using the same methods, the queue is again displayed using the &#8220;perform through&#8221; syntax.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ilusing&quot;System&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ilusing&quot;System.Collections&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 alphabetQueue &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Queue&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 item &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> alphabetQueue <span style="color: #000000; font-weight: bold;">to</span> new <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Queue&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> alphabetQueue::<span style="color: #ff0000;">&quot;Enqueue&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;A item&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> alphabetQueue::<span style="color: #ff0000;">&quot;Enqueue&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;B item&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> alphabetQueue::<span style="color: #ff0000;">&quot;Enqueue&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;C item&quot;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;The initial queue is: &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> item <span style="color: #008000; font-weight: bold;">through</span> alphabetQueue<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span> item<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;De-Queue an item: &quot;</span> alphabetQueue::<span style="color: #ff0000;">&quot;Dequeue&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Afterwards is: &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> item <span style="color: #008000; font-weight: bold;">through</span> alphabetQueue<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span> item<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span></div></div>
<p>Running the above queue example gives:</p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">The initial queue is: <br />
&nbsp;A item<br />
&nbsp;B item<br />
&nbsp;C item<br />
<br />
De-Queue an item: A item<br />
<br />
Afterwards is: <br />
&nbsp;B item<br />
&nbsp;C item</div></div>
<p>Next, lets look at the &#8216;Stack&#8217; class, this is very similar, expect it uses the &#8220;Push&#8221;, &#8220;Pop&#8221; methods and we iterate through the Stack using the &#8216;perform through&#8217; syntax.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ilusing&quot;System&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ilusing&quot;System.Collections&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 alphabetStack &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Stack&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 item &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> alphabetStack <span style="color: #000000; font-weight: bold;">to</span> new <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;Stack&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> alphabetStack::<span style="color: #ff0000;">&quot;Push&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;A item&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> alphabetStack::<span style="color: #ff0000;">&quot;Push&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;B item&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> alphabetStack::<span style="color: #ff0000;">&quot;Push&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;C item&quot;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;The initial stack is: &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> item <span style="color: #008000; font-weight: bold;">through</span> alphabetStack<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span> item<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Pop item: &quot;</span> alphabetStack::<span style="color: #ff0000;">&quot;Pop&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Afterwards is: &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> item <span style="color: #008000; font-weight: bold;">through</span> alphabetStack<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span> item<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span></div></div>
<p>Running the above stack example gives:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">The initial stack is: <br />
&nbsp;C item<br />
&nbsp;B item<br />
&nbsp;A item<br />
<br />
De-Stack an item: C item<br />
<br />
Afterwards is: <br />
&nbsp;B item<br />
&nbsp;A item</div></div>
<p>As you can see using the base class library collection classes with COBOL is just as easy as using C#&#8230; so if you are already using COBOL&#8230; continue and try out the .Net base class library.. it really is very easy to use and it will make you more productive.. so please explore and enjoy .Net and its Base Class library.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/base-class-library-arrays-queues-and-stacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arrays and the .Net Base Cass Library</title>
		<link>http://www.gennard.net/blog/2009/11/arrays-and-the-net-base-cass-library/</link>
		<comments>http://www.gennard.net/blog/2009/11/arrays-and-the-net-base-cass-library/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 18:05:15 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=166</guid>
		<description><![CDATA[Carrying on from the previous blog, the user of iterators in .Net and especially .Net on COBOL can be very useful. When CLR v2.0 was introduced a few new methods in System.IO.File for block reading/writing files were introduced, these works on arrays aka &#8220;OCCURS ANY&#8221; fields. Using these APIs instead of using traditional line sequentials [...]]]></description>
			<content:encoded><![CDATA[<p>Carrying on from the previous blog, the user of iterators in .Net and especially .Net on COBOL can be very useful.</p>
<p>When CLR v2.0 was introduced a few new methods in System.IO.File for block reading/writing files were introduced, these works on arrays aka &#8220;OCCURS ANY&#8221; fields.  Using these APIs instead of using traditional line sequentials is a breath of fresh air, especially if you just want to do some code something quickly without the need of records/group items.</p>
<p>So lets.. have a little play around, lets read a &#8220;MonthNames&#8221; from the CLR, write them to disk, read them back, reverse and sort it, while display them&#8230;</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;01 Months-Array <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.Array&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 Months <span style="color: #008000; font-weight: bold;">string</span> <span style="color: #008000; font-weight: bold;">occurs</span> 12<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 Month <span style="color: #008000; font-weight: bold;">string</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; Note: the MonthsNames has 13 elements and the last element is &quot;&quot; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; and I'm not interested it it so I'll drop it by doing a &quot;ConstrainedCopy&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; with just elements I'm interested in.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.monthnames.aspx</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> Months-Array <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.Globalization.DateTimeFormatInfo&quot;</span>::<span style="color: #ff0000;">&quot;CurrentInfo&quot;</span>::<span style="color: #ff0000;">&quot;MonthNames&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.Array&quot;</span>::<span style="color: #ff0000;">&quot;ConstrainedCopy&quot;</span><span style="color: #339933;">&#40;</span>Months-Array<span style="color: #000066;">,</span> <span style="color: #993399;">0</span><span style="color: #000066;">,</span> Months<span style="color: #000066;">,</span> <span style="color: #993399;">0</span><span style="color: #000066;">,</span> Months::<span style="color: #ff0000;">&quot;Length&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> Months::<span style="color: #ff0000;">&quot;Length&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> Month <span style="color: #008000; font-weight: bold;">through</span> Months<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Normal &nbsp;-&gt; &quot;</span> Month<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; Write the array to disk</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.IO.File&quot;</span>::<span style="color: #ff0000;">&quot;WriteAllLines&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;MyMonths.txt&quot;</span><span style="color: #000066;">,</span> Months<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> Months <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; Read it back</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> Months <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.IO.File&quot;</span>::<span style="color: #ff0000;">&quot;ReadAllLines&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;MyMonths.txt&quot;</span><span style="color: #339933;">&#41;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; Reverse it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.Array&quot;</span>::<span style="color: #ff0000;">&quot;Reverse&quot;</span><span style="color: #339933;">&#40;</span>Months <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">Type</span> <span style="color: #ff0000;">&quot;System.Array&quot;</span><span style="color: #339933;">&#41;</span> &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; Display it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> Month <span style="color: #008000; font-weight: bold;">through</span> Months<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Reverse -&gt; &quot;</span> Month<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; Sort it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.Array&quot;</span>::<span style="color: #ff0000;">&quot;Sort&quot;</span><span style="color: #339933;">&#40;</span>Months <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.Array&quot;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="">*&gt; Display it</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> Month <span style="color: #008000; font-weight: bold;">through</span> Months<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;Sorted &nbsp;-&gt; &quot;</span> Month<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span></div></div>
<p>Which when executed gives us: </p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">12<br />
Normal &nbsp;-&gt; January<br />
Normal &nbsp;-&gt; February<br />
Normal &nbsp;-&gt; March<br />
Normal &nbsp;-&gt; April<br />
Normal &nbsp;-&gt; May<br />
Normal &nbsp;-&gt; June<br />
Normal &nbsp;-&gt; July<br />
Normal &nbsp;-&gt; August<br />
Normal &nbsp;-&gt; September<br />
Normal &nbsp;-&gt; October<br />
Normal &nbsp;-&gt; November<br />
Normal &nbsp;-&gt; December<br />
Reverse -&gt; December<br />
Reverse -&gt; November<br />
Reverse -&gt; October<br />
Reverse -&gt; September<br />
Reverse -&gt; August<br />
Reverse -&gt; July<br />
Reverse -&gt; June<br />
Reverse -&gt; May<br />
Reverse -&gt; April<br />
Reverse -&gt; March<br />
Reverse -&gt; February<br />
Reverse -&gt; January<br />
Sorted &nbsp;-&gt; April<br />
Sorted &nbsp;-&gt; August<br />
Sorted &nbsp;-&gt; December<br />
Sorted &nbsp;-&gt; February<br />
Sorted &nbsp;-&gt; January<br />
Sorted &nbsp;-&gt; July<br />
Sorted &nbsp;-&gt; June<br />
Sorted &nbsp;-&gt; March<br />
Sorted &nbsp;-&gt; May<br />
Sorted &nbsp;-&gt; November<br />
Sorted &nbsp;-&gt; October<br />
Sorted &nbsp;-&gt; September</div></div>
<p>That was pretty easy&#8230; and the code looks okay too&#8230; can&#8217;t be bad&#8230;</p>
<p>References : <a href="http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.monthnames.aspx">System.Globalization.DatetimeFormat</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/arrays-and-the-net-base-cass-library/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>TechEd 2009 &#8211; Keynote with Jazon and Mark</title>
		<link>http://www.gennard.net/blog/2009/11/teched-2009-keynote-with-jazon-and-mark/</link>
		<comments>http://www.gennard.net/blog/2009/11/teched-2009-keynote-with-jazon-and-mark/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 08:29:44 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[TechEd]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Vs2010]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=208</guid>
		<description><![CDATA[My boss (Mark Conway) the other day was lucky enough to demonstrate some of the wonders of next release at TechEd 2009 in the keynote with Jazon Zander&#8217;s entitled: &#8220;Visual Studio 2010: New Challenges, New Solutions&#8221; The demo shows off some of the nice features of Visual Studio 2010 and how we looking to use [...]]]></description>
			<content:encoded><![CDATA[<p>My boss (Mark Conway) the other day was lucky enough to demonstrate some of the wonders of next release at TechEd 2009 in the keynote with Jazon Zander&#8217;s entitled: &#8220;Visual Studio 2010: New Challenges, New Solutions&#8221;</p>
<p>The demo shows off some of the nice features of Visual Studio 2010 and how we looking to use it for COBOL.  I think it looks great! <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Tip: Skip to about 34 mins into it for Mark</p>
<p><a href="http://www.msteched.com/online/view.aspx?tid=1367082a-66ed-4786-9b62-25cf3be0e8b3">Click here for TechEd Online &#8211; for the actual video</a></p>
<p>And finally here is <a href="http://blogs.msdn.com/jasonz/default.aspx">Jazon Zander&#8217;s Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/teched-2009-keynote-with-jazon-and-mark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Too Iterate or not&#8230;</title>
		<link>http://www.gennard.net/blog/2009/11/too-iterate-or-not/</link>
		<comments>http://www.gennard.net/blog/2009/11/too-iterate-or-not/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 20:51:06 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[CLR]]></category>
		<category><![CDATA[COBOL]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[BaseCL]]></category>
		<category><![CDATA[iterators]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=143</guid>
		<description><![CDATA[Over the next couple of weeks, I will explore some of the reasons why I think managed environments are good for COBOL. So.. lets the show on the road&#8230; Setting up arrays/occurs items in COBOL and manipulating them can be painful. Lets look at some traditional code for playing around with a &#8220;months&#8221; table. &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Over the next couple of weeks, I will explore some of the reasons why I think managed environments are good for COBOL.</p>
<p>So.. lets the show on the road&#8230;</p>
<p>Setting up arrays/occurs items in COBOL and manipulating them can be painful.  Lets look at some traditional code for playing around with a &#8220;months&#8221; table.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;01 month-val<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;January&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;February&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;March&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;April&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;May&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;June&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;July&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;August&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;September&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;October&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;November&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;<span style="color: #008000; font-weight: bold;">FILLER</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span> &nbsp;<span style="color: #008000; font-weight: bold;">value</span> <span style="color: #ff0000;">&quot;December&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 month-tab <span style="color: #008000; font-weight: bold;">redefines</span> month-val<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;05 &nbsp;months <span style="color: #008000; font-weight: bold;">occurs</span> 12 <span style="color: #000000; font-weight: bold;">times</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10 &nbsp;month-NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> X<span style="color: #339933;">&#40;</span>10<span style="color: #339933;">&#41;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 month &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">PIC</span> 99<span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 secondQuarterMonths &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">pic</span> x<span style="color: #339933;">&#40;</span>70<span style="color: #339933;">&#41;</span><span style="color: #000066;">.</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;The months are:&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> month <span style="color: #008000; font-weight: bold;">from</span> 1 <span style="color: #008000; font-weight: bold;">by</span> 1 <span style="color: #000000; font-weight: bold;">until</span> month equals 12<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span> months<span style="color: #339933;">&#40;</span>month<span style="color: #339933;">&#41;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;The second quarter months are: &quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">string</span> months<span style="color: #339933;">&#40;</span>4<span style="color: #339933;">&#41;</span> <span style="color: #008000; font-weight: bold;">delimited</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">space</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #008000; font-weight: bold;">delimited</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">size</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; months<span style="color: #339933;">&#40;</span>5<span style="color: #339933;">&#41;</span> <span style="color: #008000; font-weight: bold;">delimited</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">space</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #008000; font-weight: bold;">delimited</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">size</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; months<span style="color: #339933;">&#40;</span>6<span style="color: #339933;">&#41;</span> <span style="color: #008000; font-weight: bold;">delimited</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">space</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">into</span> secondQuarterMonths<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">on</span> <span style="color: #008000; font-weight: bold;">overflow</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;FATAL Error - secondQuarterMonths is too small&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">stop</span> <span style="color: #008000; font-weight: bold;">run</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-string</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span> secondQuarterMonths</div></div>
<p>Now, imagine we can use one or two of the .Net&#8217;s base class libraries combined with some nifty natural extensions to COBOL to do some of the heavy lifting.</p>
<p>Defining the month item as a native .Net type ie: a string combined with using the base class libraries Split methods allows us to setup a array quickly.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; 01 commaDelimited &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">string</span> <span style="color: #008000; font-weight: bold;">value</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;January,February,March,April,May,June,July,August,&quot;</span> &amp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;September,October,November,December&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; 01 months &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">string</span> <span style="color: #008000; font-weight: bold;">occurs</span> <span style="color: #008000; font-weight: bold;">any</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; 01 month &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">string</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; 01 secondQuarterMonths &nbsp;<span style="color: #008000; font-weight: bold;">string</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> months <span style="color: #000000; font-weight: bold;">to</span> commaDelimited::<span style="color: #ff0000;">&quot;Split&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">','</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;The months are: &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> month <span style="color: #008000; font-weight: bold;">through</span> months<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span> month<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">end-perform</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;The second quarter months are: &quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> secondQuarterMonths <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.String&quot;</span>::<span style="color: #ff0000;">&quot;Join&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #ff0000;">'/'</span><span style="color: #000066;">,</span> months<span style="color: #000066;">,</span> 3<span style="color: #000066;">,</span> 3<span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span> secondQuarterMonths</div></div>
<p>The .Net version, besides being smaller feels much easier to read, especially if you have any exposure to the .Net base class library from other languages such as C# or VB.Net.</p>
<p>Of course in a real world example, we don&#8217;t need to use the split method to setup an array, we could just use the &#8220;values&#8221; clause&#8230; for example:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; 01 months &nbsp;<span style="color: #008000; font-weight: bold;">string</span> <span style="color: #008000; font-weight: bold;">occurs</span> 12 <span style="color: #008000; font-weight: bold;">values</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;January&quot;</span> <span style="color: #ff0000;">&quot;February&quot;</span> <span style="color: #ff0000;">&quot;March&quot;</span> <span style="color: #ff0000;">&quot;April&quot;</span> <span style="color: #ff0000;">&quot;May&quot;</span> <span style="color: #ff0000;">&quot;June&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;July&quot;</span> <span style="color: #ff0000;">&quot;August&quot;</span> <span style="color: #ff0000;">&quot;September&quot;</span> <span style="color: #ff0000;">&quot;October&quot;</span> <span style="color: #ff0000;">&quot;November&quot;</span> <span style="color: #ff0000;">&quot;December&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;01 month <span style="color: #008000; font-weight: bold;">string</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> month <span style="color: #008000; font-weight: bold;">through</span> months<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> month<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span></div></div>
<p>If however you don&#8217;t want to hardcode the months, you can always use: CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName() in the System.Globalization namespace. <img src='http://www.gennard.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>So&#8230; lets just do it&#8230;</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;01 Months <span style="color: #008000; font-weight: bold;">string</span> <span style="color: #008000; font-weight: bold;">occurs</span> <span style="color: #008000; font-weight: bold;">any</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 Month <span style="color: #008000; font-weight: bold;">string</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> Months <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #008000; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;System.Globalization.DateTimeFormatInfo&quot;</span>::<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;CurrentInfo&quot;</span>::<span style="color: #ff0000;">&quot;MonthNames&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">perform</span> <span style="color: #000000; font-weight: bold;">varying</span> Month <span style="color: #008000; font-weight: bold;">through</span> Months<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> Month<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">end-perform</span></div></div>
<p>Now, I hope you feel like I do that COBOL and .Net are indeed perfect partners to each other.</p>
<hr />
<p>The above COBOL .Net code will execute on Micro Focus Net Express and I suspect it will also work on Fujitsu&#8217;s netCobol too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/too-iterate-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NUnit and COBOL.Net</title>
		<link>http://www.gennard.net/blog/2009/11/nunit-and-cobol-net/</link>
		<comments>http://www.gennard.net/blog/2009/11/nunit-and-cobol-net/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 19:44:44 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=126</guid>
		<description><![CDATA[A while back, I spent a afternoon converting some C# NUnit documentation into COBOL .Net, so I thought I would share the document with the world, with the hope that it will help any one interested in using NUnit and COBOL. Enjoy! Let’s start with a simple example. Suppose we are writing a bank application [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I spent a afternoon converting some C# NUnit documentation into COBOL .Net, so I thought I would share the document with the world, with the hope that it will help any one interested in using NUnit and COBOL.</p>
<p>Enjoy!</p>
<hr />
<p>Let’s start with a simple example. Suppose we are writing a bank application and we have a basic domain class – Account. Account supports operations to deposit, withdraw, and transfer funds. The Account class may look like this:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> Account <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Account&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">environment</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">configuration</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">repository</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">data</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 balance comp-2 <span style="color: #008000; font-weight: bold;">value</span> 0 property <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-amount comp-2<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-amount<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">add</span> lnk-amount <span style="color: #000000; font-weight: bold;">to</span> balance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;Withdraw&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-amount comp-2<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-amount<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">subtract</span> lnk-amount <span style="color: #008000; font-weight: bold;">from</span> balance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;Withdraw&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-Account &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-amount &nbsp; &nbsp;comp-2<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-Account<span style="color: #000066;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-amount<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">class</span> Account<span style="color: #000066;">.</span></div></div>
<p>Now let’s write a test for this class – AccountTest. The first method we will test is TransferFunds.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set preservecase </span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> AccountTest <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;AccountTest&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">environment</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">configuration</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">repository</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> sys-single&nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;System.Single&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> cls-TestFixture <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;NUnit.Framework.TestFixtureAttribute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> cls-<span style="color: #008000; font-weight: bold;">Test</span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;NUnit.Framework.TestAttribute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> Assert &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;NUnit.Framework.Assert&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> cls-Account &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;Account&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-attributes</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> cls-TestFixture<span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">static</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">data</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">static</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span> <span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> cls-<span style="color: #008000; font-weight: bold;">Test</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 src &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 dest&nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> src <span style="color: #000000; font-weight: bold;">to</span> cls-Account::<span style="color: #ff0000;">&quot;New&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>200<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> dest <span style="color: #000000; font-weight: bold;">to</span> cls-Account::<span style="color: #ff0000;">&quot;New&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> dest::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>150<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #339933;">&#40;</span>dest<span style="color: #000066;">,</span> 100<span style="color: #339933;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> Assert::<span style="color: #ff0000;">&quot;AreEqual&quot;</span><span style="color: #339933;">&#40;</span>250 <span style="color: #008000; font-weight: bold;">as</span> sys-single<span style="color: #000066;">,</span>dest::<span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> Assert::<span style="color: #ff0000;">&quot;AreEqual&quot;</span><span style="color: #339933;">&#40;</span>100 <span style="color: #008000; font-weight: bold;">as</span> sys-single<span style="color: #000066;">,</span>src::<span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">program</span> AccountTest<span style="color: #000066;">.</span></div></div>
<p>The first thing to notice about this class is that it has a TestFixture attribute associated with it – this is the way to indicate that the class contains test code (this attribute can be inherited). The class has to be public and there are no restrictions on its superclass. The class also has to have a default constructor.</p>
<p>The only method in the class – TransferFunds, has a Test attribute associated with it – this is an indication that it is a test method. Test methods have to return void and take no parameters. In our test method we do the usual initialization of the required test objects, execute the tested business method and check the state of the business objects. The Assert class defines a collection of methods used to check the post-conditions and in our example we use the AreEqual method to make sure that after the transfer both accounts have the correct balances (there are several overloadings of this method, the version that was used in this example has the following parameters : the first parameter is an expected value and the second parameter is the actual value).</p>
<p>Compile and run this example. Assume that you have compiled your test code into a Example1.dll. Start the NUnit Gui (the installer will have created a shortcut on your desktop and in the “Program Files” folder), after the GUI starts, select the File->Open menu item, navigate to the location of your bank.dll and select it in the “Open” dialog box. When the bank.dll is loaded you will see a test tree structure in the left panel and a collection of status panels on the right. Click the Run button, the status bar and the TransferFunds node in the test tree turn red – our test has failed. The “Errors and Failures” panel displayed the following message – “TransferFunds : expected <250> but was <150>” and the stack trace panel right below it reported where in the test code the failure has occurred  “at AccountTest.TransferFunds() in xxxx\Example1\Example1\AccountTest.cbl:line 42”</p>
<p>That is expected behavior; the test has failed because we have not implemented the TransferFunds method yet. Now let’s get it to work. Don’t close the GUI and go back to your IDE and fix the code, make your TransferFunds method look like this:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-Account &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-amount &nbsp; &nbsp;comp-2<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-Account<span style="color: #000066;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-amount<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> lnk-Account::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>lnk-amount<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> self::<span style="color: #ff0000;">&quot;Withdraw&quot;</span><span style="color: #339933;">&#40;</span>lnk-amount<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span></div></div>
<p>Now recompile your code and click the run button in GUI again – the status bar and the test tree turn green. (Note how the GUI has reloaded the assembly automatically for you; we will keep the GUI open all the time and continue working with our code in IDE and write more tests).</p>
<p>Let’s add some error checking to our Account code. We are adding the minimum balance requirement for the account to make sure that banks continue to make their money by charging your minimal overdraft protection fee. Let’s add the minimum balance property to our Account class:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;01 minimumBalance&nbsp; &nbsp; comp-2 <span style="color: #008000; font-weight: bold;">value</span> 10 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;MinimumBalance&quot;</span><span style="color: #000066;">.</span></div></div>
<p>We will use an exception to indicate an overdraft:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> InsufficientFundsException &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;InsufficientFundsException&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">inherits</span> cls-<span style="color: #008000; font-weight: bold;">exception</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">repository</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> cls-<span style="color: #008000; font-weight: bold;">exception</span> <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;System.ApplicationException&quot;</span><span style="color: #000066;">.</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">class</span> InsufficientFundsException<span style="color: #000066;">.</span></div></div>
<p>Add two new classes reference to the repository:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> ExpectedException <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;NUnit.Framework.ExpectedExceptionAttribute&quot;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class</span> InsufficientFundsException <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;InsufficientFundsException&quot;</span></div></div>
<p>Add a new test method to our AccountTest class:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFunds&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> cls-<span style="color: #008000; font-weight: bold;">Test</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> ExpectedException<span style="color: #339933;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">type</span> <span style="color: #008000; font-weight: bold;">of</span> InsufficientFundsException<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 src &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 dest&nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> src <span style="color: #000000; font-weight: bold;">to</span> cls-Account::<span style="color: #ff0000;">&quot;New&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>200<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> dest <span style="color: #000000; font-weight: bold;">to</span> cls-Account::<span style="color: #ff0000;">&quot;New&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> dest::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>150<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #339933;">&#40;</span>dest<span style="color: #000066;">,</span> 300<span style="color: #339933;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFunds&quot;</span><span style="color: #000066;">.</span></div></div>
<p>This test method in addition to Test attribute has an ExpectedException attribute associated with it – this is the way to indicate that the test code is expecting an exception of a certain type; if such an exception is not thrown during the execution – the test will fail. </p>
<p>Compile your code and go back to the GUI. As you compiled your test code, the GUI has grayed out and collapsed the test tree as if the tests were not run yet (GUI watches for the changes made to the test assemblies and updates itself when the structure of the test tree has changed – e.g. new test is added). Click the “Run” button – we have a red status bar again. We got the following Failure : “TransferWithInsufficentFunds : InsufficientFundsException was expected”. Let’s fix our Account code again, modify the TransferFunds method this way:
</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-Account &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-amount &nbsp; &nbsp;comp-2<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-Account<span style="color: #000066;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-amount<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> lnk-Account::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>lnk-amount<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> balance<span style="color: #000066;"> - </span>lnk-amount &lt; minimumBalance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">raise</span> InsufficientFundsException::<span style="color: #ff0000;">&quot;New&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> self::<span style="color: #ff0000;">&quot;Withdraw&quot;</span><span style="color: #339933;">&#40;</span>lnk-amount<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span></div></div>
<p>Compile and run the tests – green bar. Success! But wait, looking at the code we’ve just written we can see that the bank may be loosing money on every unsuccessful funds Transfer operation. Let’s write a test to confirm our suspicions. Add this test method:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFundsAtomicity&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> cls-<span style="color: #008000; font-weight: bold;">Test</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 src &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 dest&nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 obj-InsufficientFundsException <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> InsufficientFundsException<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> src <span style="color: #000000; font-weight: bold;">to</span> cls-Account::<span style="color: #ff0000;">&quot;New&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>200<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">set</span> dest <span style="color: #000000; font-weight: bold;">to</span> cls-Account::<span style="color: #ff0000;">&quot;New&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> dest::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>150<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #339933;">&#40;</span>dest<span style="color: #000066;">,</span> 300<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">catch</span> obj-InsufficientFundsException<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">continue</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; end-<span style="color: #008000; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> Assert::<span style="color: #ff0000;">&quot;AreEqual&quot;</span><span style="color: #339933;">&#40;</span>200 <span style="color: #008000; font-weight: bold;">as</span> sys-single<span style="color: #000066;">,</span>src::<span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> Assert::<span style="color: #ff0000;">&quot;AreEqual&quot;</span><span style="color: #339933;">&#40;</span>150 <span style="color: #008000; font-weight: bold;">as</span> sys-single<span style="color: #000066;">,</span>dest::<span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #339933;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFundsAtomicity&quot;</span><span style="color: #000066;">.</span></div></div>
<p>We are testing the transactional property of our business method – all operations are successful or none. Compile and run – red bar. OK, we’ve made $300.00 out of a thin air (1999.com déjà vu?) – the source account has the correct balance of 150.00 but the destination account shows : $450.00. How do we fix this? Can we just move the minimum balance check call in front of the updates:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-Account &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnk-amount &nbsp; &nbsp;comp-2<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span> <span style="color: #008000; font-weight: bold;">using</span> <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-Account<span style="color: #000066;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">by</span> <span style="color: #008000; font-weight: bold;">value</span> lnk-amount<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">if</span> balance<span style="color: #000066;"> - </span>lnk-amount &lt; minimumBalance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">raise</span> InsufficientFundsException::<span style="color: #ff0000;">&quot;New&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> lnk-Account::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>lnk-amount<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> self::<span style="color: #ff0000;">&quot;Withdraw&quot;</span><span style="color: #339933;">&#40;</span>lnk-amount<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span></div></div>
<p>What if the Withdraw() method throws another exception? Should we execute a compensating transaction in the catch block or rely on our transaction manager to restore the state of the objects? We need to answer those questions at some point, but not now; but what do we do with the failing test in the meantime – remove it? A better way is to temporarily ignore it, add the following attribute to your test method</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFundsAtomicity&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> cls-<span style="color: #008000; font-weight: bold;">Test</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> <br />
&nbsp; IgnoreTest<span style="color: #339933;">&#40;</span><span style="color: #ff0000;">&quot;Need to decide how to implement transaction management in the application&quot;</span><span style="color: #339933;">&#41;</span></div></div>
<p>Compile and run – yellow bar. Click on “Tests Not Run” tab and you will see AccountTest.TransferWithInsufficientFundsAtomicity() in the list along with the Reason this test is ignored.</p>
<p>Looking at our test code we can see that some refactoring is in order. All test methods share a common set of test objects. Let’s extract this initialization code into a setup method and reuse it in all of our tests. The refactored version of our test class looks like this:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set preservecase sourceformat&quot;free&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-id</span><span style="color: #000066;">.</span> AccountTest <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;AccountTest&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">environment</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">configuration</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">repository</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> sys-single&nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <span style="color: #ff0000;">&quot;System.Single&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> NUnit-TestFixture &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;NUnit.Framework.TestFixtureAttribute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> NUnit-<span style="color: #008000; font-weight: bold;">Test</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;NUnit.Framework.TestAttribute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> NUnit-Setup &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;NUnit.Framework.SetUpAttribute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> NUnit-Assert&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;NUnit.Framework.Assert&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> NUnit-IgnoreTest&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;NUnit.Framework.IgnoreAttribute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> NUnit-ExpectedException &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;NUnit.Framework.ExpectedExceptionAttribute&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> cls-Account &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;Account&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">class</span> InsufficientFundsException&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">as</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;InsufficientFundsException&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-attributes</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> NUnit-TestFixture<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 src &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Account<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 dest&nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> cls-Account<span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;Init&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> NUnit-Setup<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> src <span style="color: #000000; font-weight: bold;">to</span> cls-Account::<span style="color: #ff0000;">&quot;New&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">set</span> dest <span style="color: #000000; font-weight: bold;">to</span> cls-Account::<span style="color: #ff0000;">&quot;New&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>200<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> dest::<span style="color: #ff0000;">&quot;Deposit&quot;</span><span style="color: #339933;">&#40;</span>150<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;Init&quot;</span><span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> NUnit-<span style="color: #008000; font-weight: bold;">Test</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #339933;">&#40;</span>dest<span style="color: #000066;">,</span> 100<span style="color: #339933;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> NUnit-Assert::<span style="color: #ff0000;">&quot;AreEqual&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #993399;">250</span><span style="color: #000066;">,</span>dest::<span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> NUnit-Assert::<span style="color: #ff0000;">&quot;AreEqual&quot;</span><span style="color: #339933;">&#40;</span><span style="color: #993399;">100</span><span style="color: #000066;">,</span>src::<span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFunds&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> NUnit-<span style="color: #008000; font-weight: bold;">Test</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NUnit-ExpectedException<span style="color: #339933;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">type</span> <span style="color: #008000; font-weight: bold;">of</span> InsufficientFundsException<span style="color: #339933;">&#41;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #339933;">&#40;</span>dest<span style="color: #000066;">,</span> 300<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFunds&quot;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">method-id</span><span style="color: #000066;">.</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFundsAtomicity&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> NUnit-<span style="color: #008000; font-weight: bold;">Test</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">custom-attribute</span> <span style="color: #008000; font-weight: bold;">is</span> NUnit-IgnoreTest<span style="color: #339933;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;Need to decide how to implement transaction management in the application&quot;</span><span style="color: #339933;">&#41;</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 obj-InsufficientFundsException <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span> InsufficientFundsException<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> src::<span style="color: #ff0000;">&quot;TransferFunds&quot;</span><span style="color: #339933;">&#40;</span>dest<span style="color: #000066;">,</span> 300<span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">catch</span> obj-InsufficientFundsException<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">continue</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; end-<span style="color: #008000; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> NUnit-Assert::<span style="color: #ff0000;">&quot;AreEqual&quot;</span><span style="color: #339933;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 200 <span style="color: #008000; font-weight: bold;">as</span> sys-single<span style="color: #000066;">,</span>src::<span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> NUnit-Assert::<span style="color: #ff0000;">&quot;AreEqual&quot;</span><span style="color: #339933;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 150 <span style="color: #008000; font-weight: bold;">as</span> sys-single<span style="color: #000066;">,</span>dest::<span style="color: #ff0000;">&quot;Balance&quot;</span><span style="color: #339933;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">exit</span> <span style="color: #008000; font-weight: bold;">method</span><span style="color: #000066;">.</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">method</span> <span style="color: #ff0000;">&quot;TransferWithInsufficientFundsAtomicity&quot;</span><span style="color: #000066;">.</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">object</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end</span> <span style="color: #008000; font-weight: bold;">program</span> AccountTest<span style="color: #000066;">.</span></div></div>
<p>Note that Init method has the common initialization code, it has void return type, no parameters, and it is marked with SetUp attribute. Compile and run – same yellow bar!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/nunit-and-cobol-net/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Debugger &#8211; Animator</title>
		<link>http://www.gennard.net/blog/2009/11/visual-debugger-animator/</link>
		<comments>http://www.gennard.net/blog/2009/11/visual-debugger-animator/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 01:13:59 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[Animator]]></category>
		<category><![CDATA[Debugger]]></category>
		<category><![CDATA[YouTube]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=104</guid>
		<description><![CDATA[This is a very old advertisement of our (Micro Focus) first COBOL debugger called animator in all its glory debugging the classic sample of the day pi.cbl, which calculates the value of PI. So why is so good? To put it in some kind of context, most debuggers at the time were command line based, [...]]]></description>
			<content:encoded><![CDATA[<p>This is a very old advertisement of our (Micro Focus) first COBOL debugger called animator in all its glory debugging the classic sample of the day pi.cbl, which calculates the value of PI.</p>
<p>So why is so good?</p>
<p>To put it in some kind of context, most debuggers at the time were command line based, much like gdb, dbx but far less sophisticated.   So having a debugger that actually shows the execution of flow of your, query variables, monitor variables was truly application was amazing.</p>
<p>I have no idea, who put this on YouTube but it really does bring back some old memories.  So thank you!</p>
<p><object style="width: 425px; height: 350px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="Animator" /><param name="src" value="http://www.youtube.com/v/72sAtDkDRws" /><embed style="width: 425px; height: 350px;" type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/72sAtDkDRws" name="Animator"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/visual-debugger-animator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object COBOL/Java default exception handler</title>
		<link>http://www.gennard.net/blog/2009/11/object-coboljava-default-exception-handler/</link>
		<comments>http://www.gennard.net/blog/2009/11/object-coboljava-default-exception-handler/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 22:16:54 +0000</pubDate>
		<dc:creator>spgennard</dc:creator>
				<category><![CDATA[COBOL]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Interop]]></category>

		<guid isPermaLink="false">http://www.gennard.net/blog/?p=49</guid>
		<description><![CDATA[While working on some support recently for our compiler (Micro Focus COBOL compiler that is), I became annoyed with the lack of a reasonable error messages/stack trace output from our Java/COBOL Object support. I have no idea why our default exception handler for Java exceptions just displays a such a simple message with little or [...]]]></description>
			<content:encoded><![CDATA[<p>While working on some support recently for our compiler (Micro Focus COBOL compiler that is), I became annoyed with the lack of a reasonable error messages/stack trace output from our Java/COBOL Object support.</p>
<p>I have no idea why our default exception handler for Java exceptions just displays a such a simple message with little or no information.   </p>
<p>For those who have not seen it, display something similar to:</p>
<div class="codecolorer-container text blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Exception 65537 not trapped by the class javaexceptionmanager.<br />
Description: &quot;Java exception&quot;<br />
Test error<br />
Hit T to terminate program. Hit any other key to continue.<br />
instantiated - test <br />
<br />
Exception 65537 not trapped by the class javaexceptionmanager.<br />
Description: &quot;Java exception&quot;<br />
Test error<br />
Hit T to terminate program. Hit any other key to continue.</div></div>
<p>Luckily for me and you, we do expose a mechanism for replacing the default exception handler.</p>
<p>Anyway, with very little effort I created a different &#8220;default&#8221; system exception handler that display this instead:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">instantiated - test 1<br />
java.lang.Exception: Test error<br />
&nbsp; &nbsp; &nbsp; &nbsp; at SimpleClass.TestException(SimpleClass.java:10)<br />
<br />
WARNING: JavaException: Test error<br />
instantiated - test 2<br />
java.lang.Exception: Test error<br />
&nbsp; &nbsp; &nbsp; &nbsp; at SimpleClass.TestException(SimpleClass.java:10)<br />
WARNING: JavaException: Test error</div></div>
<p>The key difference being that a Java stack trace is included, boy did this help me.</p>
<p>The program below is the code that implements the exception handler.  I am sure someone else can take this example and make it much nicer and provide more features but for this blog I will keep it simple.</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #a0a0a0; font-style: italic;">$set ooctrl (+p-f) case</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">program-id</span><span style="color: #000066;">.</span> ExceptionCatcher<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-control</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EntryCallback <span style="color: #008000; font-weight: bold;">is</span> <span style="color: #008000; font-weight: bold;">class</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;entrycll&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;JavaExceptionManager <span style="color: #008000; font-weight: bold;">is</span> <span style="color: #008000; font-weight: bold;">class</span> &nbsp; <span style="color: #ff0000;">&quot;javaexpt&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ExceptionManager <span style="color: #008000; font-weight: bold;">is</span> <span style="color: #008000; font-weight: bold;">class</span> &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;exptnmgr&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Javasup <span style="color: #008000; font-weight: bold;">is</span> <span style="color: #008000; font-weight: bold;">class</span> <span style="color: #ff0000;">&quot;javasup&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 wsCallback &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 wsIterator &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 theJavaException &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 <span style="color: #008000; font-weight: bold;">filler</span> <span style="color: #008000; font-weight: bold;">pic</span> x<span style="color: #000066;">.</span> &nbsp; <span style="">*&gt; dummy storage item to allow recursion</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">linkage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnkException &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnkErrorObject &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnkErrorTextCollection &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 lnkErrorNumber &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">pic</span> x<span style="color: #339933;">&#40;</span>4<span style="color: #339933;">&#41;</span> <span style="color: #008000; font-weight: bold;">comp-5</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 anElement &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt;---Set up system level Exception handler</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> EntryCallback <span style="color: #ff0000;">&quot;new&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z<span style="color: #ff0000;">&quot;JException&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">returning</span> wsCallback<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> ExceptionManager <span style="color: #ff0000;">&quot;register&quot;</span> <span style="color: #008000; font-weight: bold;">using</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; javaexceptionmanager<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsCallback<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> EntryCallback <span style="color: #ff0000;">&quot;new&quot;</span> <span style="color: #008000; font-weight: bold;">using</span> z<span style="color: #ff0000;">&quot;DispError&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> wsIterator<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">goback</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">entry</span> <span style="color: #ff0000;">&quot;Jexception&quot;</span> <span style="color: #008000; font-weight: bold;">using</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lnkException <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lnkErrorNumber<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lnkErrorTextcollection<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> javasup <span style="color: #ff0000;">&quot;exceptionOccurred&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">returning</span> theJavaException<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">end-invoke</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">if</span> theJavaException <span style="color: #008000; font-weight: bold;">not</span> <span style="color: #008000; font-weight: bold;">equal</span> <span style="color: #008000; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> theJavaException <span style="color: #ff0000;">&quot;printStackTrace&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">end-if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> lnkErrorTextCollection <span style="color: #ff0000;">&quot;do&quot;</span> <span style="color: #008000; font-weight: bold;">using</span> wsIterator<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">goback</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">entry</span> <span style="color: #ff0000;">&quot;DispError&quot;</span> <span style="color: #008000; font-weight: bold;">using</span> anElement<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;WARNING: JavaException: &quot;</span> <span style="color: #008000; font-weight: bold;">with</span> <span style="color: #008000; font-weight: bold;">no</span> <span style="color: #008000; font-weight: bold;">advancing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000; font-weight: bold;">invoke</span> anElement <span style="color: #ff0000;">&quot;display&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot; &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">goback</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">.</span></div></div>
<p>To use the above code, you just have to first cut-paste to code into a file called ExceptionCatcher.cbl and include this in your project, and then add the directive INITCALL&#8221;ExceptionCatcher&#8221;, then away you go.</p>
<p>My test programs for the above example are:</p>
<div class="codecolorer-container cobol blackboard" style="border: 1px solid #9F9F9F;width:435px;"><div class="cobol codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp;<span style="color: #a0a0a0; font-style: italic;">$set ooctrl (+p-f) case</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">program-id</span><span style="color: #000066;">.</span> jtest<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">class-control</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SimpleClass <span style="color: #008000; font-weight: bold;">is</span> <span style="color: #008000; font-weight: bold;">class</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;$JAVA$SimpleClass&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">working-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 theInstance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">object</span> <span style="color: #008000; font-weight: bold;">reference</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">local-storage</span> <span style="color: #000080; font-weight: bold;">section</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;01 <span style="color: #008000; font-weight: bold;">filler</span> <span style="color: #008000; font-weight: bold;">pic</span> x<span style="color: #000066;">.</span> &nbsp; <span style="">*&gt; dummy storage to allow the local entry</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">procedure</span> <span style="color: #008000; font-weight: bold;">division</span><span style="color: #000066;">.</span><br />
&nbsp; &nbsp; &nbsp; <span style="">*&gt;---Instantiate the class</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> SimpleClass <span style="color: #ff0000;">&quot;new&quot;</span> <span style="color: #000000; font-weight: bold;">returning</span> theInstance<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;instantiated - test 1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> theInstance <span style="color: #ff0000;">&quot;TestException&quot;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">display</span> <span style="color: #ff0000;">&quot;instantiated - test 2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">invoke</span> theInstance <span style="color: #ff0000;">&quot;TestException&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000; font-weight: bold;">stop</span> <span style="color: #008000; font-weight: bold;">run</span><span style="color: #000066;">.</span></div></div>
<p>and the Java class itself:</p>
<div class="codecolorer-container java blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.*</span> <span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleClass <span style="color: #009900;">&#123;</span> <br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> SimpleClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> TestException<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test error&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>References: <a href="http://supportline.microfocus.com/documentation/books/nx60/nx60indx.htm">Studio Enterprise 6.0 Document for COBOL/Java Interop</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gennard.net/blog/2009/11/object-coboljava-default-exception-handler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
