<?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; BaseCL</title>
	<atom:link href="http://www.gennard.net/blog/tag/basecl/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>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>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>
	</channel>
</rss>
