Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cobol's comp3
Message
From
29/03/2007 17:02:33
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
29/03/2007 14:26:20
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01209986
Message ID:
01210073
Views:
19
This message has been marked as the solution to the initial question of the thread.
>Hi..
>
>what is the best deal on the conversion from old comp3 cobol format data to ascii?

Take it as a string, then chop by nibbles. Reserve the rightmost nibble for the sign. That is, IIRC, comp-3 was a BCD number, right?

Assume you have a byte from anywhere in the middle. Its value is then
Func Bcd2Num
para bcd
priv x
x=''
#define tbl1 ':;<=>?'
#define tbl2 'abcdef'
for i=1 to len(bcd)
	_asc = asc(subs(bcd,i))
	x=x+chr(bitshift(_asc,4)+48)+chr(bitand(_asc,15)+48)
endf
x=chrtran(x,tbl1,tbl2)
retu val(left(x,len(x)-1)) * iif(inlist(right(x,1),'c','f'),1,-1)
Wrote that on 9. March 1999, when these bit-oriented functions were in fPath.plb. Also keep in mind that this routine has no idea how many decimals does the result have. You'll have to divide it with 100 or whatever.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform