pl1 character string constant declaration



IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS

pl1 character string constant declaration

Postby Galwegian44 » Tue Apr 02, 2019 1:43 am

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
Galwegian44
 
Posts: 7
Joined: Tue Apr 02, 2019 1:36 am
Has thanked: 2 times
Been thanked: 0 time

Re: pl1 character string constant declaration

Postby prino » Tue Apr 02, 2019 10:07 am

dcl whatever char(80) init ((40)'**');
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy

These users thanked the author prino for the post:
Galwegian44 (Tue Apr 02, 2019 2:09 pm)
User avatar
prino
 
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 29 times

Re: pl1 character string constant declaration

Postby Galwegian44 » Tue Apr 02, 2019 2:08 pm

Thank you very much Robert, seems so intuitive when you see the solution.

All the best,
Eamonn
Galwegian44
 
Posts: 7
Joined: Tue Apr 02, 2019 1:36 am
Has thanked: 2 times
Been thanked: 0 time

Re: pl1 character string constant declaration

Postby prino » Tue Apr 02, 2019 4:30 pm

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.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 29 times


Return to PL/I

 


  • Related topics
    Replies
    Views
    Last post