View previous topic :: View next topic
|
Author |
Message |
kishpra
New User
Joined: 24 May 2010 Posts: 92 Location: Pune
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
What happened when you used TRACE to see exactly what is happening. |
|
Back to top |
|
|
kishpra
New User
Joined: 24 May 2010 Posts: 92 Location: Pune
|
|
|
|
tried but had no luck |
|
Back to top |
|
|
kishpra
New User
Joined: 24 May 2010 Posts: 92 Location: Pune
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
It's working OK for me, even with the extra space. We'll need to see your TRACE output. |
|
Back to top |
|
|
kishpra
New User
Joined: 24 May 2010 Posts: 92 Location: Pune
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
It works OK for me.
Suggest that maybe you haven't read the file into the LINES. stem variable correctly.
Garry. |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
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 |
|
|
kishpra
New User
Joined: 24 May 2010 Posts: 92 Location: Pune
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
So you need another variable to collect the trash. |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
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 |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
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 |
|
|
kishpra
New User
Joined: 24 May 2010 Posts: 92 Location: Pune
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
|