Re: Need help with REDEFINES (I think)....
From: Pete Dashwood (dashwood_at_enternet.co.nz)
Date: 11/25/04
- Next message: Pete Dashwood: "Re: OT: Marriage and the family"
- Previous message: Pete Dashwood: "Re: Reading CSV-file in Excel from ACU Cobol"
- In reply to: Lueko Willms: "Re: Need help with REDEFINES (I think)...."
- Next in thread: Lueko Willms: "Re: Need help with REDEFINES (I think)...."
- Reply: Lueko Willms: "Re: Need help with REDEFINES (I think)...."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 26 Nov 2004 01:49:00 +1300
"Lueko Willms" <l.willms@jpberlin.de> wrote in message
news:9LXUmMNeflB@jpberlin-l.willms.jpberlin.de...
> . On 25.11.04
> wrote dashwood@enternet.co.nz (Pete Dashwood)
> on /COMP/LANG/COBOL
> in 30khlrF315qomU2@uni-berlin.de
> about Re: Need help with REDEFINES (I think)....
>
>
> PD> (Besides, that's the boring bit; the FUN bit is addressing the size
> PD> incompatibility... <G>)
>
> and in COBOL, there is this ON SIZE ERROR phrase, which is the
> appropriate thing to use in this case.
>
Hmmm... that is your opinion, Lueko.
I disagree.
Here's my opinion... <G>
> Maybe preceded by a IF NUMERIC check, so:
>
> IF source-variable NUMERIC
> THEN
> COMPUTE destination-variable = source-variable
> ON SIZE ERROR
> *> do the appropriate thing, e.g.
> DISPLAY
> "Hey - the source-variable " source-variable " doesn't fit!"
> NOT SIZE ERROR
> *> rejoice the happy end
> CONTINUE
> END-COMPUTE
> ELSE
> DISPLAY "The source-variable " source-variable " is not numeric!"
> END-IF
>
I see the numeric validation as separate from the size issue and IF NUMERIC
is a very poor way to check numeric input data. (certain alphas, that just
happen to be in the right position and have the right value, may be
considered signs and let through... A plus, minus, or decimal point may all
invalidate the field). If you make the numeric check device dependent (by
setting numeric attributes on a 3270 for example) your code is locked in to
a device that will do the check for you. If you then transport the code to a
different system you may find an alarming increase in the number of input
data errors.
I use a component that expects a standard device independent string and
checks each character of it to decide whether it represents a number or not,
recognising that the string may contain leading or trailing signs and a
single decimal point. It then sets properties that give me the number in
various internal and external formats. Plus a whole lot more besides.
Editing and validation of formats should occur in the presentation layer of
the system, not in the business logic.
>
>
>
> and let the compiler chose the optimumt for checking the size error
> instead of inventing the wheel anew.
>
The solution which Walter posted is simple and imaginative and it does not
preclude the compiler optimizing it. Neither does it reinvent the wheel. It
is also much more efficient (if you are bothered about that) than IF NUMERIC
( a compiler generated subroutine) or ON SIZE ERROR (another compiler
generated subroutine) because it uses a simple compare (or series of
character compares) and branch on condition. (Obviously the generated code
will vary on different platforms; I am basing the above on my experience of
IBM mainframe and the Intel platform.) I believe that the general outline
would be fairly consistent across platforms, but even if I'm wrong and there
is one (or more) platforms where IF NUMERIC and ON SIZE ERROR are INCREDIBLY
efficient, I still like Walter's solution better...<G>
The efficiency of it, while a positive factor, is not what sways me here...
it is the simple elegance of it.
The other solutions are clumsy and unwieldy in comparison.
(It is so cool, I wish I'd thought of it!)
Pete.
- Next message: Pete Dashwood: "Re: OT: Marriage and the family"
- Previous message: Pete Dashwood: "Re: Reading CSV-file in Excel from ACU Cobol"
- In reply to: Lueko Willms: "Re: Need help with REDEFINES (I think)...."
- Next in thread: Lueko Willms: "Re: Need help with REDEFINES (I think)...."
- Reply: Lueko Willms: "Re: Need help with REDEFINES (I think)...."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|