Page 1 of 1

pl1 character string constant declaration

PostPosted: Tue Apr 02, 2019 1:43 am
by Galwegian44
Hi,

I'm a newbie to PL1 and hope that someone can help with what I hope is a simple issue.

I'm declaring a constant in the program with repeating values so have defined it as follows:

DCL FIELD_A CHARACTER (80) INIT (40) '**';

However, it is giving me a compile error:
Message Line.File Message Description
IBM1352I E 8.0 The statement element '**' is invalid. The statement will be ignored.

I've tried different variations of this bit always with an error. It seems to follow any syntactical guidance I can find in PL1 manuals but obviously I am missing something here.

All help is appreciated.

Thanks in advance,
Eamonn

Re: pl1 character string constant declaration

PostPosted: Tue Apr 02, 2019 10:07 am
by prino
dcl whatever char(80) init ((40)'**');

Re: pl1 character string constant declaration

PostPosted: Tue Apr 02, 2019 2:08 pm
by Galwegian44
Thank you very much Robert, seems so intuitive when you see the solution.

All the best,
Eamonn

Re: pl1 character string constant declaration

PostPosted: Tue Apr 02, 2019 4:30 pm
by prino
Next time use the proper name for the language, it's PL/I. :mrgreen:

And for what it's worth, I think you can use
dcl whatever char (123) init ((*)'!');

in Enterprise PL/I, saving you the trouble of changing the repetition factor when the length of a string (or bounds of an array) change. And mentioning arrays, never use

dcl array(-1:33) fixed bin (31) init ((*)0);

do i = -1 to 31;
....
end;

but always

do i = lbound(array, 1) to hbound(array, 1);
....
end;

and check out the PL/I builtin functions for a lot more of similar ones that help you to avoid hardcoding bounds, lengths, etc.