The "leftmost-character-position" issue is easily resolved (though also in a 
non-standard way) by using a work pointer redefined as PIC 9(9) COMP-5, then:

01  TABLE-PTR POINTER.
01  TABLE-PTR9 REDEFINES TABLE-PTR PIC 9(9) COMP-5.
. . . .
SET TABLE-PTR TO TABLE-ADDR
COMPUTE TABLE-PTR9 = TABLE-PTR9 - LENGTH OF <WHATEVER> + 1
SET ADDRESS OF <AREA-NAME> TO TABLE-PTR

Good enough, at least until POINTER becomes a 64-bit address.  Although it does 
ASSUME that TABLE-PTR will be 31-bit clean, which AFAIK is true at least for 
all Enterprise COBOL 4.x versions.

And that future maintainers understand POINTER arithmetic.

It would be interesting if "SET <pointer> {DOWN | UP} BY 
<arithmetic-expression>" got the same result.  AFAIK that is not in the current 
COBOL definitions though, DOWN and UP are only for INDEX variables.

All of these techniques are CAVEAT EMPTOR and YMMV of course.

I agree that "OCCURS 0 to 1 DEPENDING ON . . . " should be good enough not to 
require using UNBOUNDED, which is not supported in COBOL V4.x versions.  
NOSSRANGE of course is also required for that to work.

Peter

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Bill Woodger
Sent: Monday, August 08, 2016 8:57 PM
To: [email protected]
Subject: Enterprise COBOL API for dynamic capacity tables

"leftmost-character-position

Must be an arithmetic expression. The evaluation of leftmost-character-position 
must result in a positive nonzero integer that is less than or equal to the 
number of characters in the data item referenced by data-name-1."

So, you are using undefined behaviour (and non-Standard at that).

IBM have now allowed zero to be valid for leftmost-character-position (again 
non-Standard, although I don't think it is listed as an IBM Extension). 
Negative reference-modification? No.

Of course, it is like a zero/negative subscript. Until someone comes along and 
changes the compiler, that is not allowed, but it is known exactly how it 
operates.

However, if IBM do change the compiler - what then?

I'd either look to use a separate control-area, come up with a more secure way 
of referencing an "attached" one, or remove the need for a control-area.

Out of interest, why COMP not COMP-5?

Do you feel there is a benefit to using UNBOUNDED over a plain ODO? After all, 
UNBOUNDED is an IBM Extension to allow for dynamically-sized tables (although 
not *those* dynamically-sized tables). It's tough to say then that "IBM doesn't 
allow it".

--

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to