Quantcast
Channel: Visual COBOL
Viewing all articles
Browse latest Browse all 5819

Forum Post: RE: "BY VALUE LENGTH OF directory-name SIZE 4" construct

$
0
0
Hi Austin, Certain dialects of COBOL (including the Micro Focus dialect)  support the use of a special register named "LENGTH OF". This is used in the form: LENGTH OF MY-VARIABLE-NAME and returns the size in bytes of the storage used by the variable MY-VARIABLE-NAME. So, instead of having to define a separate variable to contain the length value to be passed, you can use this register to determine the value on-the-fly. This also has the advantage that if you change the size of MY-VARIABLE-NAME, you don't have the housekeeping of also fixing the value of the associated variable where you've stored the length of MY-VARIABLE-NAME. You can find the LENGTH OF special register documented here : The SIZE keyword is actually an optional part of the CALL statement, when the BY VALUE phrase is used. The CALL BY VALUE essentially says  "let the called subprogram have its own copy of this value, rather than allowing it to access (and modify) the value here in the calling program". Since we are asking that the called routine be given its own copy, the SIZE option allows us to specify the size of the field that is dynamically created in that routine to hold this value. This is documented under General Rule 16 for the CALL statement  here . Since the CBL_GET_CURRENT_DIR routine wants a 4 byte value passed that contains the size of the target field that will receive the directory name, we can use the SIZE option to make this dynamically created field that size. Please let us know if you have any additional questions about this.

Viewing all articles
Browse latest Browse all 5819

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>