Re: Dynamically Determine Numeric PICTURE String
- From: "Rick Smith" <ricksmith@xxxxxxx>
- Date: Fri, 23 Mar 2007 20:13:54 -0500
"William M. Klein" <wmklein@xxxxxxxxxxxxxxxxx> wrote in message
news:WmYMh.43132$GU2.17414@xxxxxxxxxxxxxxxxxxxxxxxxx
Rick,something
I haven't studied your samples, but I was wondering if the '02 Standard
"HIGHEST-/LOWEST-ALGEBRAIC intrinsic functions might not be used for
like this.
--
Bill Klein
wmklein <at> ix.netcom.com
I don't see any great advantage to using those functions.
Their use would replace:
add -999999999999999999 -.999999999999999999
giving item
with:
if (lowest-algebraic (item) = 0
compute item = highest-algebraic (item)
else
compute item = lowest-algebraic (item)
end-if
However, it will work for up to 31 digits, without having
62 "9"s in the code.
The HIGHEST-ALEGBRAIC and LOWEST-ALGEBRAIC
functions also work with data that has no PICTURE string;
such as the new BINARY-CHAR, etc.; but that is outside
the scope of this program.
And another thing led to another ... and thanks to the
COBOL 85 de-edit move that I had not considered.
pic z(4),zz9.99bcr
generates
s9(7)v9(2)
So, it appears to be possible to determine the numeric
PICTURE string that holds the same values as a
numeric-edited ittem.
"Rick Smith" <ricksmith@xxxxxxx> wrote in message
news:13085kf5ukmp595@xxxxxxxxxxxxxxxxxxxxx
I question whether there is any real need for this;
but I was thinking about some parts of COBOL
and ... well ... one thing led to another.
This program works only when ANSI truncation
is in effect.
-----
$set ans85 flag"ans85" flagas"s"
identification division.
program-id. find-pic.
data division.
working-storage section.
01 item pic s9(14)v9(4) comp.
01 pic-work-area.
02 counts.
03 minus-sign pic 9(2) value 0.
03 9s-before pic 9(2) value 0.
03 9s-after pic 9(2) value 0.
02 pic-work.
03 int-part pic -9(18).
03 frac-part pic .9(18)-.
02 pic-string pic x(12) value spaces.
02 string-pos pic s9(4) binary value 0.
procedure division.
begin.
initialize pic-work-area
add -999999999999999999 -.999999999999999999
giving item
move item to int-part frac-part
inspect pic-work tallying
minus-sign for all "-"
9s-before for all "9" before "."
9s-after for all "9" after "."
move 1 to string-pos
if 9s-after > 0
string
")" delimited by size
function reverse (9s-after (1:))
delimited by "0"
"(9v" delimited by size
into pic-string
pointer string-pos
end-string
end-if
if 9s-before > 0
string
")" delimited by size
function reverse (9s-before (1:))
delimited by "0"
"(9" delimited by size
into pic-string
pointer string-pos
end-string
end-if
if minus-sign > 0
string "s"
delimited by size
into pic-string
pointer string-pos
end-string
end-if
subtract 1 from string-pos
move function reverse (pic-string (1:string-pos))
to pic-string
display pic-string (1:string-pos)
stop run.
-----
.
- Follow-Ups:
- Re: Dynamically Determine Numeric PICTURE String
- From: Roger While
- Re: Dynamically Determine Numeric PICTURE String
- References:
- Dynamically Determine Numeric PICTURE String
- From: Rick Smith
- Re: Dynamically Determine Numeric PICTURE String
- From: William M. Klein
- Dynamically Determine Numeric PICTURE String
- Prev by Date: Re: MAINFRAME ANALYST/ NSIPS/ LONG TERM
- Next by Date: Re: MAINFRAME ANALYST/ NSIPS/ LONG TERM
- Previous by thread: Re: Dynamically Determine Numeric PICTURE String
- Next by thread: Re: Dynamically Determine Numeric PICTURE String
- Index(es):
Relevant Pages
|