Hi,
IIRC in COBOL II
* max-buffer pic s9(4)comp 30. Input Max
* four pic s9(4)comp value 4. Out size.
* double space pic x(2) spaces. for stop string.
Perform Until IN-buffer(IPOS:2) = Double-space
or IPOS > max-buffer
Move IN-Buffer(IPOS -four:four) to Out-buffer.
Add 1 to IPOS
End-perform.
display Out-buffer.
** hope there is more than 2 trailing space ....
May be missing some code .
Just though..
> "Emerson, Tom # El Monte" <[log in to unmask]> 06/07/00 11:38AM >>>
Most (but not all) of these posts have overlooked a crucial aspect:
"trailing spaces " are part of "the string "... (in COBOL, anyway :) )
That's because COBOL doesn't have "strings" per se, but rather
"pre-allocated blocks of memory to be treated as character-based data".
There are convolute methods [some even shown in this thread] to deal with
these memory blocks "as if" they were "strings" as defined by more
modern-day languages, but the simple fact remains that if your "source"
memory block is defined as 30 characters, taking the right-most 4 characters
of, say, "TOM EMERSON " is going to result in " " for
most of the methods you try...
(the only ones that will get "RSON" will be ones that explicitly look for
the LAST non-blank character...)
> -----Original Message-----
> From: Peter Chong [mailto:[log in to unmask]]
> Sent: Wednesday, June 07, 2000 11:12 AM
> To: [log in to unmask]
> Subject: Re: [HP3000-L] COBOL and justifying
>
>
> I did one time or another, did same excersise on
> SPL/Transact/COBOL/QUIZ
> but, G memory fade way.
>
> During the parsing of SQL to XML converter in VB/A
>
> I came out this.
>
> 'len function to find out size of string
> 'Left to extracts only that size of string
> 'Rigt to pick up last 4 char)
>
> Dim strIn as string 'InPut Buffer
> Dim strOut as string 'outPut Buffer
>
> strOut = Right(Left(strIn,Len(strIn)),4)
>
>
>
> >>> "Newton, Ernie" <[log in to unmask]> 06/06/00
> 02:43PM >>>
> Hi all,
>
> I have a need to pluck out the four rightmost characters of a variable
> length string. The problem being that the string is
> alphanumeric and COBOL
> left-justifies those type of things. Somewhere in the deep
> recesses of my
> aged mind, I seem to recall that there is a JUSTIFY command
> available in
> COBOL. I could do an algorithm to count the characters, but
> life would be
> so much simpler if I could right-justify it.
>
> Is there such a thing? And if so, what is the syntax?
>
> Thanks,
>
>
> Ernie Newton
> Computer Systems Specialist
> Yolo County Office of Education
> [log in to unmask]
>
|