View previous topic :: View next topic |
Author |
Message |
kris_madras Beginner
Joined: 07 Apr 2004 Posts: 46 Topics: 29
|
Posted: Mon May 31, 2004 3:11 pm Post subject: Replace Option : Setting Dynamic Value....? |
|
|
Hi All.
I need an urgent solution
I have used REPLACE option in COBOL as follows...
Code: |
IF WS-STATE-CODE = "IN" THEN
REPLACE == :ST-CODE: == BY ==IN==.
IF WS-STATE-CODE NOT EQUAL "IN"
REPLACE == :ST-CODE: == BY ==OK==.
ADD 1 TO WS-:ST-CODE:-SCRIPT-FLAG-BLANK.
|
My intention is whenever WS-STATE-CODE IS "IN" then increment WS-IN-SCRIPT-FLAG-BLANK. or else
WS-OK-SCRIPT-FLAG-BLANK.
But the compiler is always assuming :-ST-CODE:- as OK because
of lateral declaration of REPLACE...(compile time) how can I set to run time(IF condition...) any alternatives....? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Jun 01, 2004 5:30 am Post subject: |
|
|
kris_madras,
Use 88 level field declarations to set the flags.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Mike Chantrey Intermediate
Joined: 10 Sep 2003 Posts: 234 Topics: 1 Location: Wansford
|
Posted: Tue Jun 01, 2004 7:01 am Post subject: |
|
|
kris, your code seems to show a basic misunderstanding. 'REPLACE' (and COPY) is done at compile time, once only. It cannot be used to dynamically modify the field names in this way.
Why didn't you just code:
Code: |
IF WS-STATE-CODE = "IN" THEN
ADD 1 TO WS-IN-SCRIPT-FLAG-BLANK
ELSE
ADD 1 TO WS-OK-SCRIPT-FLAG-BLANK.
|
As Kolusu said, you could use 88 levels as well to have a condition name instead of WS-STATE-CODE = "IN" although I'm not that keen on 88 levels personally as it means I have to look in another part of the code to see what the actual test value is. |
|
Back to top |
|
|
|
|