For Programmers: Free Programming Magazines  


Home > Archive > Cobol > December 2006 > Re: Code Clarity - Comments Invited - correction









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Code Clarity - Comments Invited - correction

2006-12-11, 6:56 pm

In article <el9eaj$mq0$1@reader2.panix.com>, <docdwarf@panix.com> wrote:

[snip]

>01 Alpha-fld pic x(50) value spaces.
>01 Char-tally pic 9(4) comp value 0.
>01 Space-tally pic 9(4) comp value 0.
>
>... and code that will Move something into Alpha-fld... consider the
>following:
>
>* reject fields that have (*condition*)
>*
> Move 0 to Char-tally, Space-tally
> Inspect Alpha-fld Tallying Char-tally
> for Characters before Initial Space
> Inspect Alpha-Fld((Char-tally + 1):)
> for all Spaces


It has been pointed out to me that I made an error here and for that I
offer my apologies; this second Inspect should read:

Inspect Alpha-Fld((Char-tally + 1):) Tallying Space-Tally
for all Spaces


> If (Char-tally + Space-tally) =
> Length of Aplha-fld
> Continue
> Else
> Perform (*condition*)-Found
> End-if
>
>The question is... what condition has been found?


Thanks for the offlist correction.

DD
Pete Dashwood

2006-12-11, 6:56 pm


<docdwarf@panix.com> wrote in message news:el9s3b$7r0$1@reader2.panix.com...
> In article <el9eaj$mq0$1@reader2.panix.com>, <docdwarf@panix.com> wrote:
>
> [snip]
>
>
> It has been pointed out to me that I made an error here and for that I
> offer my apologies; this second Inspect should read:
>
> Inspect Alpha-Fld((Char-tally + 1):) Tallying Space-Tally
> for all Spaces
>
>
>
> Thanks for the offlist correction.
>
> DD


Without intending to spoil the fun, and given the stated topic, may I offer
the following, which I believe may achieve the same objective, with much
less (and arguably, clearer...) code?

Given...

01 Alpha-fld pic x(50) value spaces.
* new...
01 alpha-chars redefines Alpha-fld.
12 af-char pic x occurs 50
indexed by af-x1.
*
01 Char-tally pic 9(4) comp value 0. *> not needed (and should be
signed on most platforms)
01 Space-tally pic 9(4) comp value 0. *> not needed (and should be
signed on most platforms)

then...

perform
varying af-x1
from 2
by 1
until J > 49
if af-char (af-x1) = space AND
af-char (af-x1 - 1) NOT = space AND
af-char (af-x1 + 1) NOT = space
perform (*condition*)-Found
exit perform *> if *condition* is only to be triggered
once, otherwise comment out this line
end-if
end-perform

Given that I have understood the problem correctly (and I'm not certain that
I have), then I believe the above will be much more efficient on most
platforms.

Inspect is powerful but it does incur overhead. Multiple inspects on the
same field are probably best avoided...

If the objective was not just to find (*condition*) but to 'correct'
(*condition*) also ( by removing it)...,
then the above is easily amended as follows...

perform
varying af-x1
from 2
by 1
until J > 49
if af-char (af-x1) = space AND
af-char (af-x1 - 1) NOT = space AND
af-char (af-x1 + 1) NOT = space
set L to af-x1
move Alpha-Field (L + 1: function LENGTH
(Alpha-Field) - L) to Alpha-Field (L:)
exit perform *> if *condition* is only to be triggered
once, otherwise comment out this line
end-if
end-perform

Pete.


2006-12-11, 6:56 pm

In article <4trrlkF15f9nbU1@mid.individual.net>,
Pete Dashwood <dashwood@removethis.enternet.co.nz> wrote:
>
><docdwarf@panix.com> wrote in message news:el9s3b$7r0$1@reader2.panix.com...

[snip]
[color=darkred]

[snip]
[color=darkred]
>Without intending to spoil the fun, and given the stated topic, may I offer
>the following, which I believe may achieve the same objective, with much
>less (and arguably, clearer...) code?


Do as seems proper, Mr Dashwood, of course... but I seem to recall someone
in this thread stating 'I'm interested in observations from the
less-experienced programmers here; perhaps The Oldsters might allow them
their say before jumping in with the usual chorus of 'Oh, that's obvious'
and 'Why didn't you...?'.'

DD
William M. Klein

2006-12-11, 6:56 pm

<docdwarf@panix.com> wrote in message news:elb13i$muc$1@reader2.panix.com...
> In article <4trrlkF15f9nbU1@mid.individual.net>,
> Pete Dashwood <dashwood@removethis.enternet.co.nz> wrote:
<snip>
[color=darkred]
>... but I seem to recall someone
> in this thread stating 'I'm interested in observations from the
> less-experienced programmers here; perhaps The Oldsters might allow them
> their say before jumping in with the usual chorus of 'Oh, that's obvious'
> and 'Why didn't you...?'.'
>
> DD


I was waiting to see if any "non-oldster" would actually comment. (So far none
have even paid a peep). Maybe "oldster" is in the eye of the poster <G> (and
no poster wants to admit to being out-of-that category).

Maybe it's time for a "are you and oldster" survey in the newsgroup?

--
Bill Klein
wmklein <at> ix.netcom.com


2006-12-11, 6:56 pm

In article <WGceh.330804$c42.275215@fe02.news.easynews.com>,
William M. Klein <wmklein@nospam.netcom.com> wrote:
><docdwarf@panix.com> wrote in message news:elb13i$muc$1@reader2.panix.com...
><snip>
>
>
>I was waiting to see if any "non-oldster" would actually comment. (So far none
>have even paid a peep).


Based on my own limited experience - some of it, granted, from the Oldene
Dayse and, perhaps, in need of re-evaluation - three days is a fair wait
for posting to get propogated across the UseNet, folks to have a chance to
read it, folks to go into their shops and dig out The Manuals to check
syntax, do a couple of compiles and then reply... but that's just me.

(I've also seen, in a few places, Warhol's 'fifteen minutes' replacing the
older labelling of 'nine-day wonder'... must have been a CPU upgrade,
someplace.)

>Maybe "oldster" is in the eye of the poster <G> (and
>no poster wants to admit to being out-of-that category).


Hence the contrasting of it with 'less-experienced'... but such
hairsplitting might best be left for the scholarly type. I'd thought of
quantifying the description with 'two-year coder'... and then thought that
I might be generous and push that out to five years... and then I
remembered the adage about '(n) years' experience versus one year's
experience (n) times'...

.... and then I thought 'Enough of trying to find loopholes in your own
logic and definitions, you are dealing with a group of decent, honorable
folks who will, in the interest of helping the 'less-experienced', err on
the side of caution, letting others have a go at what might seem, to them,
to be an inconsequential exercise rather than attempting to bolster their
egos with 'Well *my* way saves (m) bytes of core and (o) CPU cycles per
iteration'...

.... and then, once again, the quality of my thinking was made plain and
public, for all to see.

>
>Maybe it's time for a "are you and oldster" survey in the newsgroup?


Nah... it'll be easier for me to re-think my thinking.

DD

HeyBub

2006-12-11, 6:56 pm

William M. Klein wrote:
>
> Maybe it's time for a "are you and oldster" survey in the newsgroup?


You are an "oldster" if:

1. You put sequence numbers in EITHER cols 1-6 OR 73-80.
2. Your code has the NOTE command commented so it won't get flagged.
3. Your code has LABEL RECORDS STANDARD.
4. You code in upper-case.
5. You can spell "environment" without looking.

Feel free to add...


Howard Brazee

2006-12-11, 6:56 pm

On Fri, 8 Dec 2006 09:52:45 -0600, "HeyBub" <heybubNOSPAM@gmail.com>
wrote:

>You are an "oldster" if:
>
>1. You put sequence numbers in EITHER cols 1-6 OR 73-80.

me
>2. Your code has the NOTE command commented so it won't get flagged.

me
>3. Your code has LABEL RECORDS STANDARD.

not me
>4. You code in upper-case.

me
>5. You can spell "environment" without looking.

me
Oliver Wong

2006-12-11, 6:56 pm


"Pete Dashwood" <dashwood@removethis.enternet.co.nz> wrote in message
news:4trrlkF15f9nbU1@mid.individual.net...
>
> <docdwarf@panix.com> wrote in message
> news:el9s3b$7r0$1@reader2.panix.com...
>
> Without intending to spoil the fun, and given the stated topic, may I
> offer the following, which I believe may achieve the same objective, with
> much less (and arguably, clearer...) code?
>
> Given...
>
> 01 Alpha-fld pic x(50) value spaces.
> * new...
> 01 alpha-chars redefines Alpha-fld.
> 12 af-char pic x occurs 50
> indexed by af-x1.
> *
> 01 Char-tally pic 9(4) comp value 0. *> not needed (and should be
> signed on most platforms)
> 01 Space-tally pic 9(4) comp value 0. *> not needed (and should be
> signed on most platforms)
>
> then...
>
> perform
> varying af-x1
> from 2
> by 1
> until J > 49
> if af-char (af-x1) = space AND
> af-char (af-x1 - 1) NOT = space AND
> af-char (af-x1 + 1) NOT = space
> perform (*condition*)-Found
> exit perform *> if *condition* is only to be
> triggered once, otherwise comment out this line
> end-if
> end-perform
>
> Given that I have understood the problem correctly (and I'm not certain
> that I have), then I believe the above will be much more efficient on most
> platforms.


To me, it looks like Doc and Pete's code will react differently, when
Alpha-fld has the value:

" 1234567890123456789012345678901234567890
1234567 0"

- Oliver


Oliver Wong

2006-12-11, 6:56 pm


<docdwarf@panix.com> wrote in message news:el9s3b$7r0$1@reader2.panix.com...
> In article <el9eaj$mq0$1@reader2.panix.com>, <docdwarf@panix.com> wrote:
>
> [snip]
>
>
> It has been pointed out to me that I made an error here and for that I
> offer my apologies; this second Inspect should read:
>
> Inspect Alpha-Fld((Char-tally + 1):) Tallying Space-Tally
> for all Spaces
>
>
>
> Thanks for the offlist correction.


The code was clear enough to me that I had correctly guessed that there
was an error and what the correction was after seeing your original post,
but before seeing this post.

- Oliver


Pete Dashwood

2006-12-11, 6:56 pm


<docdwarf@panix.com> wrote in message news:elb13i$muc$1@reader2.panix.com...
> In article <4trrlkF15f9nbU1@mid.individual.net>,
> Pete Dashwood <dashwood@removethis.enternet.co.nz> wrote:
>
> [snip]
>
>
> [snip]
>
>
> Do as seems proper, Mr Dashwood, of course... but I seem to recall someone
> in this thread stating 'I'm interested in observations from the
> less-experienced programmers here; perhaps The Oldsters might allow them
> their say before jumping in with the usual chorus of 'Oh, that's obvious'
> and 'Why didn't you...?'.'
>
> DD



That's not fair...

First, I never stated the answer to your question.

Second, if you are really interested in helping youngsters, why only make
them analyse one solution? Perhaps comparing two possible solutions might be
a more profitable exercise, given that they will encounter multifarious
approaches and solutions to any given problem in the real world?

Third, I don't always have time to contribute here so must do so when I can.

Fourth, the solution I offered does not in any way spoil the answer to your
question, and might not even be 'correct' insofar as I may well have not
understood what the actual answer to your question is.

Fifth, I don't consider myself an oldster :-)

So, there....:-)

Pete.


Pete Dashwood

2006-12-11, 6:56 pm


"Oliver Wong" <owong@castortech.com> wrote in message
news:OBmeh.46838$4A.535961@wagner.videotron.net...
>
> "Pete Dashwood" <dashwood@removethis.enternet.co.nz> wrote in message
> news:4trrlkF15f9nbU1@mid.individual.net...
>
> To me, it looks like Doc and Pete's code will react differently, when
> Alpha-fld has the value:
>
> " 1234567890123456789012345678901234567890
1234567 0"
>
> - Oliver
>

Excellent! Thanks Oliver.

Now the question is... which is 'right'? :-) (Depends on how you interpret
the problem...)

And that comes back to Doc's fundamental question which we have not
mentioned, for fear of spoiling his fun...

I think that new COBOL programmers would gain more from doing the exercise
you undertook, (comparing two solutions) than from simply analysing one
solution (either mine or his).

I had not realised the two solutions were incronguent, so thanks for
pointing that out and I may well have misunderstood the problem (as I stated
earlier).

Pete.


Pete Dashwood

2006-12-11, 6:56 pm


"Howard Brazee" <howard@brazee.net> wrote in message
news:qj9jn2hvuei0rme8kb0o24hcl2nlhhau3r@
4ax.com...
> On Fri, 8 Dec 2006 09:52:45 -0600, "HeyBub" <heybubNOSPAM@gmail.com>
> wrote:
>
> me
> me
> not me
> me
> me


As I only comply with item 5, you have independently confirmed my
affirmation to NOT being an oldster :-)

Pete.


2006-12-11, 6:56 pm

In article <4tuc1cF14o647U1@mid.individual.net>,
Pete Dashwood <dashwood@removethis.enternet.co.nz> wrote:
>
><docdwarf@panix.com> wrote in message news:elb13i$muc$1@reader2.panix.com...
>
>That's not fair...


Life isn't fair, Mr Dashwood... and anyone who told you otherwise, lied.

>
>First, I never stated the answer to your question.


What you've posted in this thread, Mr Dashwood, can be found almost as
readily as what I have posted. The conclusions may be drawn by the
reader(s).

>
>Second, if you are really interested in helping youngsters, why only make
>them analyse one solution?


I did not 'make' anyone do anything, Mr Dashwood... I offered a chunk of
code and made some statements.

>Perhaps comparing two possible solutions might be
>a more profitable exercise, given that they will encounter multifarious
>approaches and solutions to any given problem in the real world?


Perhaps I am the King of England, Mr Dashwood... God save the Me.

DD

2006-12-11, 6:56 pm

In article <3Fmeh.46919$4A.537655@wagner.videotron.net>,
Oliver Wong <owong@castortech.com> wrote:
>
><docdwarf@panix.com> wrote in message news:el9s3b$7r0$1@reader2.panix.com...


[snip]


[snip]
[color=darkred]
>
> The code was clear enough to me that I had correctly guessed that there
>was an error and what the correction was after seeing your original post,
>but before seeing this post.


That might go towards demonstrating something about 'in the mind of the
beholder', Mr Wong, and say more about your skills at reading code than
mine at writing it. I hope you found the exercise to be at least...
amusing.

DD

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com