IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Help in REXX code


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kishpra

New User


Joined: 24 May 2010
Posts: 92
Location: Pune

PostPosted: Thu Apr 14, 2011 5:05 pm
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: 8797
Location: Welsh Wales

PostPosted: Thu Apr 14, 2011 5:16 pm
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: 92
Location: Pune

PostPosted: Thu Apr 14, 2011 5:17 pm
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: 92
Location: Pune

PostPosted: Thu Apr 14, 2011 5:19 pm
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

Global Moderator


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

PostPosted: Thu Apr 14, 2011 5:22 pm
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: 92
Location: Pune

PostPosted: Thu Apr 14, 2011 5:27 pm
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

Global Moderator


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

PostPosted: Thu Apr 14, 2011 5:33 pm
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Apr 14, 2011 5:34 pm
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: 792
Location: Pennsylvania

PostPosted: Thu Apr 14, 2011 5:36 pm
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: 765
Location: Whitby, ON, Canada

PostPosted: Thu Apr 14, 2011 5:40 pm
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: 92
Location: Pune

PostPosted: Thu Apr 14, 2011 5:40 pm
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: 8797
Location: Welsh Wales

PostPosted: Thu Apr 14, 2011 5:46 pm
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: 765
Location: Whitby, ON, Canada

PostPosted: Thu Apr 14, 2011 5:46 pm
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: 792
Location: Pennsylvania

PostPosted: Thu Apr 14, 2011 5:47 pm
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: 765
Location: Whitby, ON, Canada

PostPosted: Thu Apr 14, 2011 5:54 pm
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: 92
Location: Pune

PostPosted: Thu Apr 14, 2011 6:23 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Thu Apr 14, 2011 7:03 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top