[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[open-cobol-list] Help understanding this behaviour
From: |
Patrick |
Subject: |
[open-cobol-list] Help understanding this behaviour |
Date: |
Sun, 01 Sep 2013 19:10:43 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130809 Thunderbird/17.0.8 |
Hi Everyone
I have attached a code snippet at the end of this email.
I don't understand the behaviour of the program.
There is an outer procedure calling in inner one. There is a linkage
section.
In the outer program, if I create a record in the working storage
section and pass this, everything works in the program being called.
However if I pass a string not defined in the working storage section, a
part of a string in a paragraph from the outer program shows up later,
the "value is spaces" no longer seems to work and an unwanted value is
showing up later.
In hello world cobol programs there is no working storage. I am assuming
that when we code DISPLAY "hello world" the compiler has allocated the
memory for "hello world" but it looks like I have to create working
storage records for everything or there will be trouble later.
So specifically with this program I have a statement:
DISPLAY "why is this string showing up later"
If I pass the variable some-str the result makes sense
./confused
some <-- this is instruction-string
but if I pass the string "some" I get some of the string from a previous
display statement, "why is th"
./confused
somewhy is th <-- this is instruction-string
I don't understand why this is happening, could someone help clear it up
for me?
Thanks for reading-Patrick
>>SOURCE FORMAT FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. confused.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 some-str PIC X(17) VALUE IS "some" .
PROCEDURE DIVISION.
*>this is a problem = CALL 'stack-controller' USING "some"
CALL 'stack-controller' USING some-str
END-CALL
STOP RUN
.
100-TEST-PARA.
DISPLAY "why is this string showing up later"
.
*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDENTIFICATION DIVISION.
PROGRAM-ID. stack-controller.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 instruction-string PIC X(17) VALUE IS SPACES .
LINKAGE SECTION.
01 instruction-argument PIC X(17) .
PROCEDURE DIVISION USING
BY VALUE instruction-argument.
MOVE instruction-argument TO instruction-string
DISPLAY instruction-string WITH NO ADVANCING DISPLAY " <--
this is instruction-string"
EXIT PROGRAM.
END PROGRAM stack-controller
.
END PROGRAM confused
.
*> If I pass the variable some-str the result makes sense
*>./confused
*>some <-- this is instruction-string
*> but if I pass the string "some" I get some of the string from
the DISPLAY in 100-TEST-PARA
*>./confused
*> somewhy is th <-- this is instruction-string
- [open-cobol-list] Help understanding this behaviour,
Patrick <=
- Re: [open-cobol-list] Help understanding this behaviour, Charles Anthony, 2013/09/01
- Re: [open-cobol-list] Help understanding this behaviour, Patrick, 2013/09/01
- Re: [open-cobol-list] Help understanding this behaviour, Charles Anthony, 2013/09/01
- Re: [open-cobol-list] Help understanding this behaviour, Patrick, 2013/09/01
- Re: [open-cobol-list] Help understanding this behaviour, Wim Niemans, 2013/09/02
- Re: [open-cobol-list] Help understanding this behaviour, Brian Tiffin, 2013/09/03
- Re: [open-cobol-list] Help understanding this behaviour, Wim Niemans, 2013/09/03
- Re: [open-cobol-list] Help understanding this behaviour, Brian Tiffin, 2013/09/03
- Re: [open-cobol-list] Help understanding this behaviour, Patrick, 2013/09/03
- Re: [open-cobol-list] Help understanding this behaviour, Vincent Coen, 2013/09/07