View previous topic :: View next topic
|
Author |
Message |
surendra_mainframe
New User
Joined: 18 Oct 2005 Posts: 5
|
|
|
|
Hi,
Can anyone convert char(3) into char(2) in PL1 just like Comp3 in Cobol?
Surendra |
|
Back to top |
|
|
karthik srinivasan
New User
Joined: 07 Oct 2005 Posts: 6 Location: chennai
|
|
|
|
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 |
|
|
surendra_mainframe
New User
Joined: 18 Oct 2005 Posts: 5
|
|
|
|
But still when i am doing char(2) = char(3) , result of char(2) variable is truncating the data. |
|
Back to top |
|
|
k_vikram07
New User
Joined: 23 Nov 2005 Posts: 35
|
|
|
|
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 |
|
|
nutakkimurali
New User
Joined: 15 Nov 2005 Posts: 22
|
|
|
|
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 |
|
|
karthik srinivasan
New User
Joined: 07 Oct 2005 Posts: 6 Location: chennai
|
|
|
|
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 |
|
|
nutakkimurali
New User
Joined: 15 Nov 2005 Posts: 22
|
|
|
|
Karthik Thank you for your input
Muralee |
|
Back to top |
|
|
|