Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Help in REXX code

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Thu Apr 14, 2011 5:05 pm    Post subject: Help in REXX code
Reply with quote

Hi ,

I am reading a file which has the data as -

MTANGLB G0243V00 ASSF6683000 1
MTANGLB G0244V00 ASSF6683000 1

When I parse the above input in four variables as PARSE A B C D

I get D as ' 1'

D = STRIP(D)

But when I check D = 1

i.e.

IF D = 1
say 'i am in '
ELSE
say ''nothing'

I get nothing


Please assist.


Thanks!
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Apr 14, 2011 5:16 pm    Post subject:
Reply with quote

What happened when you used TRACE to see exactly what is happening.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Thu Apr 14, 2011 5:17 pm    Post subject: Help in REXX code
Reply with quote

tried but had no luck
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Thu Apr 14, 2011 5:19 pm    Post subject: Help in REXX code
Reply with quote

In Input -

MTANGLB G0243V00 ASSF6683000 1
MTANGLB G0244V00 ASSF6683000 1

There is only one spaces between first three variables but two spaces between 'ASSF6683000' & '1'
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Thu Apr 14, 2011 5:22 pm    Post subject: Reply to: Help in REXX code
Reply with quote

It's working OK for me, even with the extra space. We'll need to see your TRACE output.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Thu Apr 14, 2011 5:27 pm    Post subject: Help in REXX code
Reply with quote

My input file -

MTANGLB G0243V00 ASSF6683000 1
MTANGLB G0253V00 ASSF6683000 1

My program -

DO I = 1 TO LINES.0
PARSE VAR LINES.I VAR1 VAR2 VAR3 VAR6
SAY 'BEF VAR6' VAR6
VAR6 = STRIP(VAR6)
VAR1 = STRIP(VAR1)
VAR2 = STRIP(VAR2)
VAR3 = STRIP(VAR3)
SAY 'VAR6' VAR6
IF VAR6 == '1' THEN
DO
SAY 'HI'
END


I am not getting the display as 'HI'


Thanks
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Thu Apr 14, 2011 5:33 pm    Post subject: Reply to: Help in REXX code
Reply with quote

Code:

TRACE I
DO I = 1 TO LINES.0
  PARSE VAR LINES.I VAR1 VAR2 VAR3 VAR6 .
  SAY 'VAR6' VAR6 LENGTH(VAR6)
  IF VAR6 = '1' THEN
    DO
      SAY 'HI'
    END
END
TRACE N


You don't need to STRIP your PARSE'd variables. Again, we need to see your TRACE output.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Apr 14, 2011 5:34 pm    Post subject:
Reply with quote

It works OK for me.

Suggest that maybe you haven't read the file into the LINES. stem variable correctly.

Garry.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Thu Apr 14, 2011 5:36 pm    Post subject:
Reply with quote

SuperK said:
Quote:
We'll need to see your TRACE output.


But for some reason you chose to ignore this. Trace(I) would be best here.

Also please show your input data with a hex display (using code tag please).

My first guess is that the additional space you see is actually low-values.

My second guess is that you will ignore what I have asked.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Thu Apr 14, 2011 5:40 pm    Post subject:
Reply with quote

Your DO loop is incomplete. The END statement shown is referring to the DO that is subordinate to the IF, not to the DO loop.

BTW, your code works for me too. I see the 'HI' message, but only once because of the broken DO loop.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Thu Apr 14, 2011 5:40 pm    Post subject: Help in rexx Code
Reply with quote

TRACE Output -

14 *-* DO I = 1 TO LINES.0
>L> "1"
>V> "2"
15 *-* PARSE VAR LINES.I VAR1 VAR2 VAR3 VAR6

>C> "LINES.1"
>>> "MTANGLB"
>>> "G0243V00"
>>> "ASSF6683000"
>>> " 1 ??????"
17 *-* IF VAR6 == '1'
>V> " 1 ??????"
>L> "1"
>O> "0"
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Apr 14, 2011 5:46 pm    Post subject:
Reply with quote

So you need another variable to collect the trash.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Thu Apr 14, 2011 5:46 pm    Post subject:
Reply with quote

Try PARSE VAR LINES.I VAR1 VAR2 VAR3 VAR6 REST

The last variable in the PARSE contains whatever is left over in the record.

Also check your input file to confirm that there really are spaces after the "1"
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Thu Apr 14, 2011 5:47 pm    Post subject:
Reply with quote

Quote:
My first guess is that the additional space you see is actually low-values


I am close but.....


Quote:
My second guess is that you will ignore what I have asked.


I am right because...

Also please show your input data with a hex display (using code tag please).

Do you think I asked this just for the fun of it?

Why can't posters who are asking for help follow instructions?
WHY WHY WHY
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Thu Apr 14, 2011 5:54 pm    Post subject:
Reply with quote

daveporcelan wrote:
Quote:
My first guess is that the additional space you see is actually low-values


I am close but.....


Quote:
My second guess is that you will ignore what I have asked.


I am right because...

Also please show your input data with a hex display (using code tag please).

Do you think I asked this just for the fun of it?

Why can't posters who are asking for help follow instructions?
WHY WHY WHY
Because they know that other posters will jump in and give them the answer. I have been guilty of this, though usually I try to provide only an incomplete answer in the hopes that the TS will find the rest of it on his/her own.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Thu Apr 14, 2011 6:23 pm    Post subject: Help in REXX code
Reply with quote

I have spaces after '1' in the input file as my file is of 80 characters,but the below is working fine for me now -

DO I = 1 TO LINES.0
PARSE VAR LINES.I VAR1 VAR2 VAR3 VAR6 REST
VAR6 = STRIP(VAR6)



Thanks!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 14, 2011 7:02 pm    Post subject:
Reply with quote

so now you can add REXX to 'COBOL,JCL,VSAM,CICS,DB2'

in lieu of yet another variable to catch left-overs from a parse,
in this case you used the varaible rest.

you can use a . (period)

parse var first_word second_word third_word forth_word .

the . will allow the 4th and the 5th to be separated.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Thu Apr 14, 2011 7:03 pm    Post subject:
Reply with quote

You do NOT hve spces after the 1! Wht do you think the ???? are in the trace - Christms decorations? No, they re unprintable characters. You hve NOT shown us a HEX ON display of your data - maybe because you saw that there were other characters after the 1 but were too embarassed to admit it.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us