Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space
vferr094@alumni.uottawa.ca wrote:
> Hello, I am wondering if anyone knows wether there is a Cobol symbol
> representation where it can be used in the
>
> INSPECT src_var REPLACING all " ALPHANUMERIC " by " "
>
> I need to replace a space followed by any A-Z or 1-0 followed by
> another space by just a space within a string. I thought perhaps there
> is a symbol in cobol to represent all alphanumeric characters, where
> say '*' was it, something like " '*' " , does anyone know if this is
> possible?


Here's a prototype in seven (essential) statements:

COMPUTE LEN = FUNCTION LENGTH(MYSTRING) - 1
PERFORM VARYING I FROM 2 BY 1 UNTIL I > LEN
IF MYSTRING(I - 1:1) = SPACE
AND MYSTRING(I:1) PERMITTED-CHAR
AND MYSTRING (I + 1:1) = SPACE
MOVE SPACE TO MYSTRING(I:1)
END-IF
END-PERFORM

Where PERMITTED-CHAR is defined as:

CLASS PERMITTED-CHAR 'A' 'B' 'C' 'D' (etc.)



Report this thread to moderator Post Follow-up to this message
Old Post
HeyBub
11-01-07 12:55 PM


Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space
On Thu, 1 Nov 2007 07:48:11 -0500, "HeyBub" <heybubNOSPAM@gmail.com> wrote:

>vferr094@alumni.uottawa.ca wrote: 
>
>
>Here's a prototype in seven (essential) statements:
>
>   COMPUTE LEN = FUNCTION LENGTH(MYSTRING) - 1
>   PERFORM VARYING I FROM 2 BY 1 UNTIL I > LEN
>    IF MYSTRING(I - 1:1) = SPACE
>     AND MYSTRING(I:1) PERMITTED-CHAR
>     AND MYSTRING (I + 1:1) = SPACE
>     MOVE SPACE TO MYSTRING(I:1)
>     END-IF
>    END-PERFORM
>
>Where PERMITTED-CHAR is defined as:
>
>CLASS PERMITTED-CHAR 'A' 'B' 'C' 'D' (etc.)

That will eliminate words one letter long. The question was how to eliminate
 alphabetic
words of any length.

Report this thread to moderator Post Follow-up to this message
Old Post
Robert
11-01-07 11:55 PM


Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space
"Robert" <no@e.mail> wrote in message
 news:3jpji3dq3sjk2424kvs012km63fsch6nf0@
4ax.com...
> On Thu, 1 Nov 2007 07:48:11 -0500, "HeyBub" <heybubNOSPAM@gmail.com> wrote
:
> 
>
> That will eliminate words one letter long. The question was how to elimina
te
> alphabetic
> words of any length.

Robert,
What makes you say that was the original question?  (read above or to quote
...

"I need to replace a space followed by any A-Z or 1-0 followed by another sp
ace
by just a space"

the word "all" appears in "to represent all alphanumeric" but it still appea
rs
to be talking about a single character.

Now, the OP *may* have wanted a routine to replace a "word" - but that wasn'
t
how I read the request.

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



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
11-01-07 11:55 PM


Re: Help with Inspect _src_ replacing all [SPACE]ALPHANUMERIC[SPACE] by space
vferr094@alumni.uottawa.ca wrote:
> William M. Klein wrote: 
>
> Hey guys!
>
> Well, I tried the suggestion above, and sure enough it worked.
>
> I am sorry for not originally describing the problem very clearly. It
> was somewhere along the lines...
>
> I have a string say-  ' big fresh a apple'
> I needed to scrapout the a and replace it with a space, I realize this
> will give me double spaces, but I have a routine later that scrubs off
> additional spaces, which was why I didnt care.
>
> I would have picked perl if I could have done it in any other
> language, the thing is, had to be done in Cobol. I'm a java programmer
> who's been working with Cobol for the last while, so I am still
> transitioning and not quite an expert on it :)
> Thanks again, Van

Ah,

MOVE 1 TO PTR
MOVE 1 TO I
MOVE SPACE TO WORDS.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 50
UNSTRING MYSTRING DELIMITED BY ' ' INTO WORD(I) WITH POINTER PTR
END-PERFORM.

MOVE SPACE TO MYSTRING
MOVE 1 TO PTR
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 50
IF WORD(I)(2:1) NOT = SPACE
STRING WORD(I) DELIMITED SPACE
' ' DELIMITED SIZE
INTO MYSTRING WITH POINTER PTR
END-IF
END-PERFORM



Report this thread to moderator Post Follow-up to this message
Old Post
HeyBub
11-01-07 11:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:09 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.