Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
How can we compress char length in PL1?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & ASSEMBLER
Author Message
surendra_mainframe

New User


Joined: 18 Oct 2005
Posts: 5

PostPosted: Wed Nov 23, 2005 6:49 pm    Post subject: How can we compress char length in PL1?
Reply with quote

Hi,

Can anyone convert char(3) into char(2) in PL1 just like Comp3 in Cobol?


Surendra
Back to top
View user's profile Send private message
References
karthik srinivasan

New User


Joined: 07 Oct 2005
Posts: 6
Location: chennai

PostPosted: Wed Nov 23, 2005 7:32 pm    Post subject: Re: How can we compress char length in PL1?
Reply with quote

HI Surendra,

I am not sure of compressing technique in PL1 , but for the situtation which u are facing you can declare the variable as

DCL ABC CHAR(2) VARYING

when a variable is declared as varying, the srorage allocation for the variable is 2 + 2 bytes ( in extra).

I hope this helps

Thanks
Karthik Srinivasan
Back to top
View user's profile Send private message
surendra_mainframe

New User


Joined: 18 Oct 2005
Posts: 5

PostPosted: Wed Nov 23, 2005 8:02 pm    Post subject: Thanx Karthik
Reply with quote

But still when i am doing char(2) = char(3) , result of char(2) variable is truncating the data.
Back to top
View user's profile Send private message
k_vikram07

New User


Joined: 23 Nov 2005
Posts: 34

PostPosted: Wed Nov 23, 2005 8:17 pm    Post subject:
Reply with quote

I don't think we can do this in any language either in Cobol or PL1.

The cobol comp-3 is not for char. it is for numeric.

We do have such a thing for numeric items in Pl1. But not for Char.

You may however raise a condition to stop this truncation if it ever happens.


Thanks
Vik.
Back to top
View user's profile Send private message
nutakkimurali

New User


Joined: 15 Nov 2005
Posts: 22

PostPosted: Fri Nov 25, 2005 11:55 am    Post subject: Re: How can we compress char length in PL1?
Reply with quote

Hi karthi,

Why it allocates 2+2 when u dec the 2 bytes variable with varying option

Please let me know

DCL ABC CHAR(2) VARYING

when a variable is declared as varying, the srorage allocation for the variable is 2 + 2 bytes ( in extra).

Muralee
Back to top
View user's profile Send private message
karthik srinivasan

New User


Joined: 07 Oct 2005
Posts: 6
Location: chennai

PostPosted: Fri Nov 25, 2005 2:20 pm    Post subject: Re: How can we compress char length in PL1?
Reply with quote

HI Murali...

The two bytes which is being added is for storing the length of the string.
THE LEFT MOST 2 BYTES CONTAIN THE LENGTH OF THE STRING

ie) 2 bytes ( this is for char(2) ) + 2 bytes ( this is for storing the length )

Hope this helps.....

Thanks & Regards
Karthik Srinivasan
Back to top
View user's profile Send private message
nutakkimurali

New User


Joined: 15 Nov 2005
Posts: 22

PostPosted: Fri Nov 25, 2005 3:47 pm    Post subject: Re: How can we compress char length in PL1?
Reply with quote

Karthik Thank you for your input

Muralee
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & ASSEMBLER All times are GMT + 6 Hours
Page 1 of 1