Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Extent of CHAR(...) VAR?

27 views
Skip to first unread message

Peter J. Seymour

unread,
Mar 7, 2013, 7:57:14 AM3/7/13
to
Tutorial time.
I can't find how to determine the maximum length that a CHAR VAR field
can take without making an assumption about the length prefix. In the
past, I have always simply made the field "more than large enough". I
suppose one question would be: is the prefix always the same length and
in the same place regardless of implementation?
Any ideas on a method?
Thanks

Shmuel Metz

unread,
Mar 7, 2013, 12:41:40 PM3/7/13
to
In <N80_s.172$Dm1...@fx01.fr7>, on 03/07/2013
at 12:57 PM, "Peter J. Seymour" <Newsg...@pjsey.demon.co.uk>
said:

>I can't find how to determine the maximum length that a CHAR VAR
>field can take without making an assumption about the length
>prefix.

For what implimentation? Enterprise PL/I for z/OS, PL/I for AIX and
Rational Developer for System z PL/I for Windows all have MAXLENGTH().

--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spam...@library.lspace.org

Peter J. Seymour

unread,
Mar 7, 2013, 3:50:50 PM3/7/13
to
On 2013-03-07 17:41, Shmuel (Seymour J.) Metz wrote:
> In <N80_s.172$Dm1...@fx01.fr7>, on 03/07/2013
> at 12:57 PM, "Peter J. Seymour" <Newsg...@pjsey.demon.co.uk>
> said:
>
>> I can't find how to determine the maximum length that a CHAR VAR
>> field can take without making an assumption about the length
>> prefix.
>
> For what implimentation? Enterprise PL/I for z/OS, PL/I for AIX and
> Rational Developer for System z PL/I for Windows all have MAXLENGTH().
>
The write up is not entirely clear so it is a case of try it and see.
MAXLENGTH does indeed do what I want. So it is down to a question of
whether I am taking compatibility too far into the past. I don't think
there is an answer to that.
Anyway thanks for the solution.

James J. Weinkam

unread,
Mar 7, 2013, 4:39:23 PM3/7/13
to
Peter J. Seymour wrote:
> Tutorial time.
> I can't find how to determine the maximum length that a CHAR VAR field can take without making an assumption about the
> length prefix. In the past, I have always simply made the field "more than large enough".

What field are you making more than large enough? If you just want a local string that can contain the largest number of
characters that can be assigned to your varying length string, x, just

dcl y char(maxlength(x)) var;

If you really need to know the total storage requirement for x, then what you want is size(x) which is the sum of
maxlength and the number of bytes in the length prefix.

I suppose one question would
> be: is the prefix always the same length and in the same place regardless of implementation?

The short answer is no.

The language definition does not specify a maximum string length; that is an implementation restriction. Not all
implementations use a length prefix; the F compiler placed both the maximum and current lengths in the dope vector. More
accurately it knew the maximum length from the declaration and kept the current length off to the side in an anonymous
compiler generated variable (of course the length built in function returned this value so it was available to the
programmer); it only actually built a string dope vector if it needed to pass it somewhere.

I know of no implementation that has a maximum string length greater that 32767. Others may know of an example if there
is one. A few months back Robin showed a kludge for getting some of the effects of strings longer than 32767 but it is
undocumented, not transparent, and only applicable in very limited circumstances.

> Any ideas on a method?

See above.
> Thanks

Shmuel Metz

unread,
Mar 7, 2013, 5:00:19 PM3/7/13
to
In <O47_s.1682$wa4....@fx18.fr7>, on 03/07/2013
at 08:50 PM, "Peter J. Seymour" <Newsg...@pjsey.demon.co.uk>
said:

>So it is down to a question of
>whether I am taking compatibility too far into the past.

Well, I can tell you how to get the maximum length for F and
"optimizing".

Robin Vowels

unread,
Mar 7, 2013, 6:06:22 PM3/7/13
to
On Mar 7, 11:57 pm, "Peter J. Seymour" <Newsgro...@pjsey.demon.co.uk>
wrote:
MAXLENGTH is what you want.
It was first introduced in PL/I for OS/2 in 1994,
and is in all of IBM's current PL/I compilers.

In earlier compilers, it wasn't necessary to make any assumptions.
The maximum length was available.
The declared length also was available.

Peter J. Seymour

unread,
Mar 8, 2013, 3:04:06 AM3/8/13
to
On 2013-03-07 12:57, Peter J. Seymour wrote:
I am probably being over-concerned about backwards compatibility. I
think I am being a bit unsettled by being uncertain what the current
"standard" is. In practical terms it is probably the OS/2 compiler. As I
understand it, the IBM strategy for moving forward from the Optimiser
was to produce an entirely new compiler for OS/2 and to port that
version back to the mainframe. This would make any of their
post-Optimiser compilers closely related. I seem to remember the OS/2
compiler being under development in the late 80's.

Robin Vowels

unread,
Mar 8, 2013, 4:04:16 AM3/8/13
to
On Mar 8, 7:04 pm, "Peter J. Seymour" <Newsgro...@pjsey.demon.co.uk>
wrote:
Version 1 release 1 was 1994.

Peter Flass

unread,
Mar 8, 2013, 8:01:24 AM3/8/13
to
If IBM isn't going to release the control block formats maybe we need to
reverse-engineer them and post them on a blog or wiki or some other of
those new-fangled contraptions. Previously this information was
available, albeit buried in the Debug Reference. If I get some time
(Ha!) maybe I can look at the OS/2 compiler, which is all I have.

I do know that the argument list format has changed from the Optimizer -
instead of a pointer to a locator/descriptor (or a pointer to data, it
depends) - they now have (I believe) a list of pointers to data followed
by a corresponding list of pointers to descriptors, some of which may or
may not be present.

--
Pete

Robin Vowels

unread,
Mar 8, 2013, 9:28:41 AM3/8/13
to
On Mar 9, 12:01 am, Peter Flass <Peter_Fl...@Yahoo.com> wrote:
> On 3/8/2013 4:04 AM, Robin Vowels wrote:
>
> > On Mar 8, 7:04 pm, "Peter J. Seymour" <Newsgro...@pjsey.demon.co.uk>
> > wrote:
> >> On 2013-03-07 12:57, Peter J. Seymour wrote:
> >> I am probably being over-concerned about backwards compatibility. I
> >> think I am being a bit unsettled by being uncertain what the current
> >> "standard" is. In practical terms it is probably the OS/2 compiler. As I
> >> understand it, the IBM strategy for moving forward from the Optimiser
> >> was to produce an entirely new compiler for OS/2 and to port that
> >> version back to the mainframe. This would make any of their
> >> post-Optimiser compilers closely related. I seem to remember the OS/2
> >> compiler being under development in the late 80's.
>
> > Version 1 release 1 was 1994.
>
> If IBM isn't going to release the control block formats maybe we need to
> reverse-engineer them and post them on a blog or wiki or some other of
> those new-fangled contraptions.  Previously this information was
> available, albeit buried in the Debug Reference.  If I get some time
> (Ha!) maybe I can look at the OS/2 compiler, which is all I have.

IBM's current Programmer's Guide has details of descriptors.

John W Kennedy

unread,
Mar 8, 2013, 12:03:22 PM3/8/13
to
I /think/ there is some confusion here between maximum length of
CHAR(...) VAR variables (which is pretty universally 32767) and maximum
length of a particular CHAR(*) VAR variable, which, before MAXLENGTH
was introduced, could only be obtained by using assembler to obtain the
dope vector, descriptor, or locator/descriptor.

--
John W Kennedy
Having switched to a Mac in disgust at Microsoft's combination of
incompetence and criminality.

Robin Vowels

unread,
Mar 8, 2013, 5:58:32 PM3/8/13
to
The (max) length of a particular CHAR VAR was available
where it was declared, and that value could be passed anywhere,
if required.
Not necessary to write assembler.

Peter J. Seymour

unread,
Mar 9, 2013, 4:56:46 AM3/9/13
to
I see that there is an option to have different versions of descriptors
for compatibility reasons. That seems at the same time both sensible and
weird. I haven't got time to investigate further at present.

wolfgang zeidler

unread,
Mar 9, 2013, 10:03:24 AM3/9/13
to
In older
PL/I for MVS & VM
you may use the builtin function STORAGE:
STORAGE ( var_char) = MAXLENGTH ( var_char ) + 2

http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/ibm3l101/16.5.105

--
http:\wzwz.de\mail

John W Kennedy

unread,
Mar 9, 2013, 2:50:35 PM3/9/13
to
Utterly useless for a library routine.

> and that value could be passed anywhere,
> if required.

You could also delete LENGTH, DIM, HBOUND, and LBOUND from the language
the same way. But most people would regard that as idiotic.

> Not necessary to write assembler.

Except, y'know, to be useful.

--
John W Kennedy
"The poor have sometimes objected to being governed badly; the rich
have always objected to being governed at all."
-- G. K. Chesterton. "The Man Who Was Thursday"

0 new messages