View previous topic :: View next topic
|
Author |
Message |
vishal kumar gupta Warnings : 1 New User
Joined: 18 Feb 2007 Posts: 11 Location: bhubaneswar
|
|
|
|
hi,
can any body suggest me how can how to perform Unstring verb in cobol if i dont know the exact number of tokens after unstring is performed. ie if i dont want to use a fixed number of working storage variable in the "INTO" clause of Unstring verb ,
like
unstring abc delimited by all spaces into ws-patterns end unstring,
problem is i dont know the number of vlaues coming in ws-patterns, is there any way to know that |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Use an array for the targets. |
|
Back to top |
|
|
vishal kumar gupta Warnings : 1 New User
Joined: 18 Feb 2007 Posts: 11 Location: bhubaneswar
|
|
|
|
1)how to know whether the string has ended
2) if i write
unstring abc-shpr(sub) delimited by all spaces into ws-pattern(sub)
this is what ur saying then will all the delimited tokens be stored?reply |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
You can unstring each field in a perform loop until overflow using the pointer function of the unstring to maintain position.
And because you are going to ask, something like this:
Code: |
move 1 to P
perform varying sub from 1 by 1
until UOVER
unstring field delimited by thingy
into area(sub)
with pointer P
on overflow set UOVER to true
end-unstring
end-perform |
|
|
Back to top |
|
|
vishal kumar gupta Warnings : 1 New User
Joined: 18 Feb 2007 Posts: 11 Location: bhubaneswar
|
|
|
|
thanks a lot |
|
Back to top |
|
|
vishal kumar gupta Warnings : 1 New User
Joined: 18 Feb 2007 Posts: 11 Location: bhubaneswar
|
|
|
|
HI ,
A small problem , how to declare a pointer ,
either usage as pointer in this case its showing severe errors
or as any numeric variable
suggest |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
vishal kumar gupta Warnings : 1 New User
Joined: 18 Feb 2007 Posts: 11 Location: bhubaneswar
|
|
|
|
Code: |
PERFORM VARYING WS-SUB2 FROM 1 BY 1
UNTIL WS-UNTIL-OVER-SW = 'Y'
UNSTRING CMBL16M1-CMBL16M1-LINE(SUB)
DELIMITED BY ALL SPACES
INTO WS-DELIMITED-PATTERN-NEW(WS-SUB2)
WITH POINTER WS-POINTER
ON OVERFLOW MOVE 'Y' TO WS-UNTIL-OVER-SW
END-UNSTRING
END-PERFORM |
see the whole code is exploding , here the program is copying only the first element of the field in pattern-new array.But i want to copy the whole broken tokens into the array ,
:-( |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I'm sorry, but I don't see the "exploding"?
It looks like it should work, why is it exiting the perform? |
|
Back to top |
|
|
vishal kumar gupta Warnings : 1 New User
Joined: 18 Feb 2007 Posts: 11 Location: bhubaneswar
|
|
|
|
i have declared ws-pointer as
01 WS-POINTER-P.
05 WS-POINTER PIC S9(3).
array
WS-DELIMITED-PATTERN-NEW as
01 WS-DELIMITED-TABLE-NEW .
05 WS-TABLE-PATTERN-NEW OCCURS 20.
10 WS-DELIMITED-PATTERN-NEW PIC X(40).
i dont know why it is not working . suggest what could go wrong? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Code: |
display 'limit ' WS-UNTIL-OVER-SW
display '>>>' CMBL16M1-CMBL16M1-LINE(SUB) '<<<'
PERFORM VARYING WS-SUB2 FROM 1 BY 1
UNTIL WS-UNTIL-OVER-SW = 'Y'
display 'limit in ' WS-UNTIL-OVER-SW
display 'pointer in ' WS-POINTER
UNSTRING CMBL16M1-CMBL16M1-LINE(SUB)
DELIMITED BY ALL SPACES
INTO WS-DELIMITED-PATTERN-NEW(WS-SUB2)
WITH POINTER WS-POINTER
ON OVERFLOW
display 'overflow ' WS-POINTER
MOVE 'Y' TO WS-UNTIL-OVER-SW
END-UNSTRING
display 'unstrung ' WS-SUB2
display 'pointer out ' WS-POINTER
display 'limit in ' WS-UNTIL-OVER-SW
END-PERFORM |
Let's see what this shows.... |
|
Back to top |
|
|
vishal kumar gupta Warnings : 1 New User
Joined: 18 Feb 2007 Posts: 11 Location: bhubaneswar
|
|
|
|
sorry its a cobio (idms dc) display doesnt work here ,
sorry i didnt tell u earlier, |
|
Back to top |
|
|
|