I don't think that will work because the upper nibble will come out to be effectively multiplied by 16, not 10. E.g.: hex 21 is decimal 33, not decimal 21. To handle different lengths, could you just substitute len(S) for the 6?
...Jim
>Well, after careful thought I realize that I was trying too hard to come up with a generic algorithm, that fit all cases abd all lengths. Your example did not work for me but gave me the idea to simplify.
>
>I have a fixed length, so I all I need is to keep shifting numbers:
>
>* sample string (should translate to $31.05)
>S = CHR(02)+CHR(00)+CHR(00)+CHR(00)+CHR(31)+CHR(05)
>Y = 0
>for I = 2 to 6
> C = asc(substr(S,I,1))
> * just shift the previous accumulated result to the left
> Y = (Y * 100) + C
>endfor
>Y = Y / 100
>if left(S,1) = chr(01)
> Y = - Y
>ENDIF
>
>
>So, your message got me thinking.
>I must be getting old, not seeing how simple it was, and trying to do it the hard way. Thanks.