View previous topic :: View next topic
|
Author |
Message |
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
I have converted the comp-3 data into displayable format. Its working fine in most of the cases but in some cases it is displaying the value wrong
Ex: if the data is 78787 , it is displaying as 7c7c7
According to my observation it is displaying C for 8 and D for 9
Suggest me on how to correct the problem
with regards,
surya |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Post your code to let us see exactly what you are doing. |
|
Back to top |
|
|
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
The code for conversion from comp-3 to displayable format is as follows:
data=c2x(input)
sign=right(data,1)
datas=substr(data,1,length(datas)-1)
if sign = 'D' then
number = '-' || datas
This is what iam doing......
It is working well for most of the inputs except for some of then as i have told in the previous post
with regards,
surya |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
Yeah!!! I have checked your post and that is what i have done
i am putting the full code here:
ARG INPUT_DATA LEN DEC
DATAS = C2X(INPUT_DATA)
DATAS = STRIP(DATAS,'T','0')
MAIN = LEN
DTYPE = DATATYPE(DEC)
IF DEC\ = NUM THEN DEC = 0 */
SIGN = RIGHT(DATAS,1)
DATAS = SUBSTR(DATAS,1,LENGTH(DATAS)
DATAM = SUBSTR(DATAS,1,MAIN)
DATAD = SUBSTR(DATAS,(MAIN+1),DEC)
IF DEC\ = 0 THEN
NUMBER = DATAM||'.'||DATAD
ELSE
NUMBER = DATAM
IF SIGN = 'D' THEN
NUMBER='-'||NUMBER
OUTPUT_DATA = NUMBER
RETURN OUTPUT_DATA
But it is not working in some cases as i have mentioned.
It is displaying C for 8 and D for 9
with regards,
surya |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
Can you please tell me what is the difference because i didnt find any difference and
one more thing is one of the line is mistyped in my code
it is actually
DATAS = SUBSTR(DATAS,1,LENGTH(DATAS)-1)
i forgot to subtract 1
with regards,
surya |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
did You look at the link...
review the difference between
Code: |
ARG something
and
PARSE ARG something
|
|
|
Back to top |
|
|
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
Yeah i have the seen the link....
Actually whatever i have put here is an internal subroutine. I am calling this subroutine whenever i encounter a comp-3 field
So Arg is correct
surya |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Then it should work, and we have just thrown away some bandwidth
Code: |
/*REXX- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
Trace "O"
string = "0123456789abcdef"x
chars = c2x(hex)
say "string" string
say "chars " chars
call ok string
call ko_arg string
call ko_low string
call ko_upp string
exit
ok: procedure
parse arg string
chars = c2x(string)
say "ok" chars
return 0
ko_arg: procedure
arg string
chars = c2x(string)
say "ko_arg" chars
return 0
ko_low: procedure
parse lower arg string
chars = c2x(string)
say "ko_low" chars
return 0
ko_upp: procedure
parse upper arg string
chars = c2x(string)
say "ko_upp" chars
return 0
|
I never post without testing |
|
Back to top |
|
|
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
Hey!!! excellent. I got my mistake. i never thought that would be my mistake.
But why is the output changing from arg to parse arg.
can u please throw some light on this
thanks a lot
surya |
|
Back to top |
|
|
|