View previous topic :: View next topic
|
Author |
Message |
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Hi Friends
I have been getting this below problem. Could anybody please help out in this.
When testing one of our applications, we are running into a very strange bug.
In the code below we found is that the XFILE-BUFFER still contain low-values instead of spaces after initialization. We tried different compilers Cobol 4 or Cobol 5 and still encountered the same issue.
What is strange is that by duplicating this same line of code, it corrects the issue by initializing XFILE-BUFFER to spaces. If we removed this one line, we can recreate the issue again i.e. the buffer is set with low-values.
Code: |
001663 156400* INITIALIZE X FILE:
001664 156610 MOVE SPACES TO XFILE-BUFFER. This is the original code
001665 156611 MOVE SPACES TO XFILE-BUFFER. This is the same line we added !!
001666 156620 DISPLAY 'XFILE-INIT:' XFILE-INIT (1:16).
001667 156800 DISPLAY 'XFILE-BUFFER CCC SPACES:' XFILE-BUFFER (1:16).
|
Any help will be greatly appreciated.
Thanks
Changed from quoted text to coded text - spacing now correct |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Is XFILE-BUFFER part of an FD? If so, the NORMAL initialization will be to LOW-VALUES. |
|
Back to top |
|
|
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Hi Robert
Thanks for that. Even if XFILE BUFFER is part of FD . The statement MOVE SPACES TO XFILE BUFFER (not initialisation) should move spaces to it. Not sure then why we need two move spaces to space this out. |
|
Back to top |
|
|
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Sorry I am not at work now so can't check if it's part of FD or not |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I think you need to understand that the variables associated with a file (everything in the FD for that file) are NOT part of your program -- they are associated with the buffer used to pass data between the operating system and your program. I have seen unexpected results occur many times where someone believes the FD variables can be treated like WORKING-STORAGE variables; this simply is not true. For example, referencing an FD variable before the associated file is opened or after it is closed will NOT have good results -- often resulting in a storage violation ABEND, for example. If XFILE-BUFFER is part of an FD, then do not expect it to work like a WORKING-STORAGE variable. |
|
Back to top |
|
|
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Thanks Robert. Very nice explanation. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
Back to top |
|
|
|