[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GNU-COBOL] edit program qs? (was PIC)
At 02:45 PM 10/27/99 , Ken Brakey wrote:
>Chad Slaughter wrote:
>
> > Randall Bart wrote :>
> > >
> > >though some are tediously detailed. The most tedious of all is PICTURE.
> >
> > I would agree.
>
>Why? dataname, format
>picture is the keyword that attaches that format to dataname
>description of format:
>A alphabetic
>X alphanumeric
>9 numeric
>B blank leading zeroes
>$ float dollar sign
>* fill leading spaces with asterisks
>V places decimal point
>, formats comma (like dec pt. CAN be placed anywhere even wrong)
You left out ., DB, CR, +, -, /, Z, and S. We're not saying it's hard;
we're saying it's tediously detailed. Would you like to write this routine?
> > >Which brings up a question: Has anyone written a Cobol edit program? In
> >
> > what is this?? I dont understand what this progrma is doing. Could
> > you please explain?
> > I have never used cobol on a mainframe.
Imagine a field PRINT-AMT with PIC $$$,$$$.99. When we move a value into
PRINT-AMT, we should get nicely edited string. Examples:
Value String
.01 " $.01"
12.34 " $12.34"
123.45 " $123.45"
1,234.56 " $1,234.56"
> > >olden times, when I wrote mainframe compilers, we were always
> compiling for
> > >specific edit op-codes, and the details were always different. Failing to
> >
> > edit op-codes??
Yes, edit op-codes. In IBM there are at least six op-codes for editing, on
Unisys A Series there are at least seven. On both of these systems there
are two instructions which have an operand containing an "edit mask"
(IBM-speak) or "edit table" (Unispeak) which is actually a simple edit
program. On A Series an edit table might be something like:
set-zero-suppression
set-float-char "$"
transfer-digits-conditional 3
insert-conditional ","
transfer-digits-conditional 3
insert-unconditional "."
transfer-digits-unconditional 2
On CISC mainframes you needed to have this kind of editing tool in the
microcode, or Cobol performance would be abysmal. Performance at that
level is no longer necessary. Our equivalent to a microcoded edit op-code
is a program that we can call from a Perl or C++ or whatever program.
> > > edit <value> <pic> [-b] [-s[l|t][s]]
I have an ocean of Burroughs/Unisys knowledge and a shot glass of
Linux/Unix, so correct me if I don't have the conventions correct. I think
what I am envisioning is a program which you could call in a shell like this:
`edit 123.45 $$$,$$$.99`
and it would return this:
" $123.45"
The old mainframe edit op-codes required the compiler to digest the PIC,
but in this case the program should use the actual Cobol picture string,
supplemented by switches for whatever needs special handling.
--
RB |\ Randall Bart
aa |/ Barticus@usa.net 818-985-3259 Barticus@att.net
nr |\ 8321 Burnet Av #1, North Hills, CA 91343
dt ||\
a |/ Y2K website: http://users.aol.com/PanicYr00
l |\
l |/ DOT-HS-808-065 I Love You MS^7=6/28/107
--
This message was sent through the gnu-cobol mailing list. To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body. For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.