Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Bill Woodger wrote: |
[...]
The CALL x USING ADDRESS OF y behaves like this:
Cobol tucks tucks the address of your item in a little piece of storage that you have no accesss to. Passing it as a parameter is fine, but attempting to change it in the called program is entirely pointless, as there is no lasting relationship between the tucked-away storage and your definition.
In this instance, since you don't have any storage for that yet, the address would be NULL anyway, so not only useless to the calling program, useless to the called program as well.
[...]
|
Sorry dejunzhu, I got the above wrong. The description I gave for how it works is for BY CONTENT on the USING. You have, implicitly, BY REFERENCE.
For BY REFERENCE, with an item in the Linkage Section, you can amend the ADDRESS OF in a called program.
There is mention in the manual that "identifier-2" should have addressability prior to the CALL, but it is not clear if this comment applies to the "identifier-2" in the ADDRESS OF. It is also potentially one of those situations where "must" in the Cobol manual means "should".
Now, for problem determination, changing the address of something directly (the program is passing the actual BLL Cell) in another module does not sound like such a good idea to me. It should work, but will have made the logic more obscure.
If you ever do it that way, make sure it is clearly documented/commented for/in the calling and called modules, please.
The clearer way to do it, as dbz already suggested on this point, is to set to a POINTER in the caller, change the value of that in the called, then set the address from the POINTER in the caller when you get back after the call. |
|