Hello Patrick
COBOL fields are not NULL terminated.
C Strings are NULL terminated.
MOVING 4 bytes into a field only affects those 4 bytes (some COBOL
compilers), the rest of the
field is the same as before MOVING into COBOL field. The NULL
character
will be in the 5th position in your example. You have to strip off
the
NULL termination character before it can be used in COBOL and you
have
to add a NULL to a Calling C variable. Other wise garbage on both
sides.
Numbers can be more fun. Open COBOL has some good notes I think
at:
Gary Cutler's OpenCOBOL Programmer's Guide.
http://opencobol.add1tocobol.com/OpenCOBOL%20Programmers%20Guide.pdf
(3.3M)
I always initialize a COBOL receiving string to SPACES before
MOVING
a massaged C-String into it.
McNary
On 9/1/2013 7:53 PM, Patrick wrote:
Hi Charles
Thanks for answering my post !
So I see were you are going with this, 17 bytes expected, 4 sent
but why would the calling procedure tack on 13 bytes of junk?
The calling procedure does not have knowledge of what is
expected to be received, wouldn't it just send what is enclosed
in the quotes?
I actually just changed it to X(50) and the whole string "why is
this string showing up later" gets sent along with the value
enclosed in quotes.
At the end of the day, if I have to send only values defined in
working storage, it's not a big deal, it's just that I don't
really get the logic behind this.
Thanks for helping me to narrow the problem down to the calling
side, I thought it was on the receiving end and thanks again for
posting-Patrick
On 09/01/2013 08:36 PM, Charles Anthony wrote:
[COBOL newbie here; this may be wrong.]
LINKAGE SECTION.
01 instruction-argument PIC X(17)
states that the argument is PIC X(17); when you pass in
"some", only four bytes are allocated and initialized. The
subroutine, expecting 17 bytes, picks up the "some" plus the
following 13 bytes which happen to be where the constant
"why ....".
-- Charles
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list