Code Comments
Programming Forum and web based access to our favorite programming groups.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.)
Post Follow-up to this messageOn 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.
Post Follow-up to this message"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
Post Follow-up to this messagevferr094@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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.