At least VS COBOL II, as far as I can remember.  This is when CICS added the 
COBOL2 translate option to allow the LENGTH argument to be omitted, since it 
used LENGTH OF under the covers.
Also, it's called a "special register" rather than built-in function; though 
now there is also an intrinsic function LENGTH, as well as BYTE-LENGTH.

One thing that LENGTH OF will do that the others won't is allow you to get the 
length of a table element without subscripting it, e.g.

01  my-table.
    05  my-entry occurs 10 times.
        10  me-one   pic x(8).
        10  me-two   pic s9(9) comp.

call 'something' using my-table, content length of my-entry

The LENGTH OF special register and the BYTE-LENGTH function both return the 
number of bytes of a field.  The LENGTH function will return the number of 
"characters" for both USAGE DISPLAY and USAGE NATIONAL, meaning LENGTH 
OF/BYTE-LENGTH function for a PIC N(10) returns 20, while LENGTH function 
returns 10.

For the new UTF-8 it seems to do its own thing that I have not researched yet.  
But so far it returns 10 for all 3, even though it allocates 40 bytes for a PIC 
U(10).  I'm sure there is some logic behind it.

-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of 
Phil Smith III
Sent: Saturday, May 20, 2023 5:09 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: LENGTH OF in COBOL (was: ISPF HILITE Question)

Since when does COBOL have LENGTH OF? I looked for this about 12 years ago and 
didn't find it, wrote a tiny and trivial assembler function to do the same 
thing. Did I miss it, or is it new since then?

 

Not that the code has needed any support, but I'm glad that if it ever becomes 
an issue, I can say "Use the BIF instead"!


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to