View previous topic :: View next topic
|
Author |
Message |
hsbawari Currently Banned New User
Joined: 16 Sep 2008 Posts: 9 Location: chennai
|
|
|
|
I have one character variable defined as
DCL X char(100);
However the current value in X is numeric with 4 digits say '0120'
Now I need to get this numeric value. how should my numeric variable declared in which I will hav the value extracted from the text?
Can any one help me??
Its a PL/I code. |
|
Back to top |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
This May Solve your problem
Code: |
DCL X FIXED BINARY(31,0);
DCL Y CHAR(04) INIT('0123');
X=BINARY(Y); |
|
|
Back to top |
|
|
hsbawari Currently Banned New User
Joined: 16 Sep 2008 Posts: 9 Location: chennai
|
|
|
|
yeah thanks
I got another one without using built in function
DCL TIME_CHAR CHAR(4) INIT('');
DCL TIME_VALID PIC'(4)9' BASED(ADDR(TIME_CHAR));
TIME_VALID=string_char
/* this would work fine now string_char can be any character string*/ |
|
Back to top |
|
|
Cary
New User
Joined: 23 Sep 2008 Posts: 3 Location: China
|
|
|
|
can not we move char to pic?
DCL TIME_CHAR CHAR(04);
DCL TIME_V PIC '9999'
TIME_V = TIME_CHAR
when time_char is numeric,
it is ok? |
|
Back to top |
|
|
cheryala
New User
Joined: 20 Mar 2006 Posts: 46
|
|
|
|
1) dcl xchar char(04) init('1234');
dcl xpic pic'(9)4' based(addr(xchar));
now you can use XPIC variable in any arithmetic expressions instead of XCHAR variable..
2) what Cary has proposed is also correct..you can directly assign character string to pic variable .. |
|
Back to top |
|
|
|