text split in rexx



IBM's Command List programming language & Restructured Extended Executor

text split in rexx

Postby venkateshm » Sun Jun 03, 2012 1:27 am

I'm working on migration. If i have a copybook in the below format, whenever line has //(double slash) it must be shifted into other line as a comment. How can I achieve this using REXX (OR MACROS).
INPUT:
01 group.
    05 st-details pic 9(8)   //student no,class
    05 st-address pic x(10)   //student address, zip-code

Desired OUTPUT:

             01 group.
                   05 st-details pic 9(8).   
          *student no,class (comment)
                   05 st-address pic x(10).   
          *student address,zipcode(comment)
venkateshm
 
Posts: 10
Joined: Sun May 13, 2012 8:57 pm
Has thanked: 0 time
Been thanked: 0 time

Re: text split in rexx

 

Re: text split in rexx

Postby MrSpock » Sun Jun 03, 2012 3:21 am

Seems relatively simple:

- Read a record.
- Look for the // in the record.
- If found, Parse the record into variables that contain the portion left of the //, and the portion to the right of the //. Write the left-side and right-side variables as seperate records. Else, just write the record as-is.
- Repeat.
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: text split in rexx

Postby venkateshm » Sun Jun 03, 2012 11:22 pm

thank you spock..
As i am new to REXX, i am not that much comfortable to achieve this in rexx. Anyway i will take your inputs and proceed further...
venkateshm
 
Posts: 10
Joined: Sun May 13, 2012 8:57 pm
Has thanked: 0 time
Been thanked: 0 time

Re: text split in rexx

Postby dick scherrer » Mon Jun 04, 2012 12:10 am

Hello,

i am not that much comfortable to achieve this in rexx.
The more you work with things, the more comfortable you will become.

If you get stuck along the way, post here what you tried and what went wrong (syntax error, abend, undesired results, etc) and someone should be able to help.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: text split in rexx

Postby enrico-sorichetti » Mon Jun 04, 2012 2:37 am

here is one way to do it ...


#! /usr/bin/rexx

stmt.1 = "01 group."
stmt.2 = "   05 st-details pic 9(8)   //student no,class"
stmt.3 = "   05 st-address pic x(10)   //student address, zip-code"
stmt.0 = 3

do  s = 1 to stmt.0
    temp = strip(stmt.s,"T")
    say "orig >>>"temp"<<<"
    parse var temp stmt "//" cmnt
    stmt = strip(stmt,"T")

    if  stmt = temp then ,
        say "orig >>>"stmt"<<<"
    else do
        stmt = stmt "."
        say "stmt >>>"stmt"<<<"
        cmnt = "*" cmnt
        say "cmnt >>>"cmnt"<<<"
    end
    say
    say
end


I did not space things properly, just a POC on how to split lines.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: text split in rexx

Postby venkateshm » Wed Jun 06, 2012 9:46 pm

Hi,
thank you for your suggestions and inputs.
enrico-sorichetti your logic helped me a lot, thanks...
I got the desired output.
venkateshm
 
Posts: 10
Joined: Sun May 13, 2012 8:57 pm
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post