Welcome to myCobol.net Saturday, 29 April 2017, 09:31 @ CEST
Cobol has no global data, i.e. data items that are shared among several program units (subroutines). The only way to pass information is to use the call parameter list. Sometimes this is obfuscating the Cobol text, e.g., when many subroutines share a large set of parameters. In such cases one can use a common block. This is a way to specify that a set of data items should be shared among subroutines. But in general, the number of common blocks should be minimized.
First there is a return-status to define. This must be set on exit to oke or error or other needed values, though one does not want to imitate the variable range of the exit status that a *nix shell is offering. We want to keep this minimalistic:
Second there is a control-request to define. This will be set before entry (calling) and specifies the action that the subroutine must perform. But beware! This item has to reflect all possible functions that one's subroutines may ever support. For subroutines that manipulate formats (date conversion, calculations, etc) there seems no need for this item and good code would still use a default value like zero for 'special'. Other subroutines need some state (like file IO) or need a modifier to tell how the function could be performed (again as in file IO for serial/random access or locking features). We want to keep this minimalistic too:
8 = close/shutdown.
The modifier would specify
This brings us to the follwing code (please note the 'x' in the names to avoid a reserved word):