1. Reading VB data

I have some accounting data written with Visual Basic.
The numbers are 8 bytes (reals, I guess).
Can anyone tell me how to read these with Euphoria?

Thanks,
Irv

new topic     » topic index » view message » categorize

2. Re: Reading VB data

Irv Mullins wrote:

>I have some accounting data written with Visual Basic.
>The numbers are 8 bytes (reals, I guess).
>Can anyone tell me how to read these with Euphoria?

With 8 bytes, my guess would be that they're float64 values. If that's the
case, read those 8 bytes into a sequence and use float64_to_atom() to
convert them into Euphoria values.

Be seeing you,
   Gabriel Boehme

new topic     » goto parent     » topic index » view message » categorize

3. Re: Reading VB data

On Mon, 24 May 1999, Boehme, Gabriel wrote:

> Irv Mullins wrote:
>
> >I have some accounting data written with Visual Basic.
> >The numbers are 8 bytes (reals, I guess).
> >Can anyone tell me how to read these with Euphoria?
>
> With 8 bytes, my guess would be that they're float64 values. If that's the
> case, read those 8 bytes into a sequence and use float64_to_atom() to
> convert them into Euphoria values.
>

Sounds like it would work, but all I got was 0.00 and -nan 's.
Also tried reversing the sequence first, with worse results.
Here's a snippet of the extracted data, along with the actual
numbers typed in for comparison:
                                   Act.$    What Euphria reads:

     JRUBBERCO  04/01/99 117329 1  21.84   {32,85,3,0,0,0,0,0}
     JRUBBERCO  04/01/99 117329 0   1.32   {144,51,0,0,0,0,0,0}
     CASH       04/01/99 117330 1   4.31   {92,168,0,0,0,0,0,0}
     CASH       04/01/99 117330 0   0.26   {40,10,0,0,0,0,0,0}
     CASH       04/01/99 117331 4 (56.66)  {184,90,247,255,255,255,255,255}
     CASH       04/01/99 117331 0  (3.40)  {48,123,255,255,255,255,255,255}
     JOHNSONEA  04/01/99 117332 1  40.38   {88,41,6,0,0,0,0,0}
     JOHNSONEA  04/01/99 117332 0   2.43   {236,94,0,0,0,0,0,0}
     CASH       04/01/99 117333 99  0.00   {0,0,0,0,0,0,0,0}
     BENTTREEC  04/01/99 117334 1  16.17   {164,119,2,0,0,0,0,0}
     BENTTREEC  04/01/99 117334 0   0.97   {228,37,0,0,0,0,0,0}
     CHASTAINF  04/01/99 117335 1   8.88   {224,90,1,0,0,0,0,0}
     CHASTAINF  04/01/99 117335 0   0.54   {24,21,0,0,0,0,0,0}
     TRNRDAVID  04/01/99 117336 1   1.12   {192,43,0,0,0,0,0,0}
     TRNRDAVID  04/01/99 117336 0   0.07   {188,2,0,0,0,0,0,0}
     CLARKJIMMY 04/01/99 117337 1  24.15   {92,175,3,0,0,0,0,0}
     CLARKJIMMY 04/01/99 117337 0   1.15   {236,44,0,0,0,0,0,0}
     PICCOCOMM  04/01/99 117338 9  86.71   {28,59,13,0,0,0,0,0}
     POOLED     04/01/99 117339 1  19.78   {168,4,3,0,0,0,0,0}
     POOLED     04/01/99 117339 0   1.19   {124,46,0,0,0,0,0,0}
    ... and so on...

Sure would appreciate some help !

Irv

new topic     » goto parent     » topic index » view message » categorize

4. Re: Reading VB data

On Mon, 24 May 1999, Boehme, Gabriel wrote:

> Irv Mullins wrote:
>
> >I have some accounting data written with Visual Basic.
> >The numbers are 8 bytes (reals, I guess).
> >Can anyone tell me how to read these with Euphoria?
>
> With 8 bytes, my guess would be that they're float64 values. If that's the
> case, read those 8 bytes into a sequence and use float64_to_atom() to
> convert them into Euphoria values.
>
Sounds good, but no luck. Just a series of 0.00 and -nan 's ...

Below is a clip of the extracted data, as Euphoria sees it. Everything
works except for the $ amounts - I have added the actual amts. so
maybe someone can tell me how to convert:

                                   Act.$    What Euphria reads:

     JRUBBERCO  04/01/99 117329 1  21.84   {32,85,3,0,0,0,0,0}
     JRUBBERCO  04/01/99 117329 0   1.32   {144,51,0,0,0,0,0,0}
     CASH       04/01/99 117330 1   4.31   {92,168,0,0,0,0,0,0}
     CASH       04/01/99 117330 0   0.26   {40,10,0,0,0,0,0,0}
     CASH       04/01/99 117331 4 (56.66)  {184,90,247,255,255,255,255,255}
     CASH       04/01/99 117331 0  (3.40)  {48,123,255,255,255,255,255,255}
     JOHNSONEA  04/01/99 117332 1  40.38   {88,41,6,0,0,0,0,0}
     JOHNSONEA  04/01/99 117332 0   2.43   {236,94,0,0,0,0,0,0}
     CASH       04/01/99 117333 99  0.00   {0,0,0,0,0,0,0,0}
     BENTTREEC  04/01/99 117334 1  16.17   {164,119,2,0,0,0,0,0}
     BENTTREEC  04/01/99 117334 0   0.97   {228,37,0,0,0,0,0,0}
     CHASTAINF  04/01/99 117335 1   8.88   {224,90,1,0,0,0,0,0}
     CHASTAINF  04/01/99 117335 0   0.54   {24,21,0,0,0,0,0,0}
     TRNRDAVID  04/01/99 117336 1   1.12   {192,43,0,0,0,0,0,0}
     TRNRDAVID  04/01/99 117336 0   0.07   {188,2,0,0,0,0,0,0}
     CLARKJIMMY 04/01/99 117337 1  24.15   {92,175,3,0,0,0,0,0}
     CLARKJIMMY 04/01/99 117337 0   1.15   {236,44,0,0,0,0,0,0}
     PICCOCOMM  04/01/99 117338 9  86.71   {28,59,13,0,0,0,0,0}
     POOLED     04/01/99 117339 1  19.78   {168,4,3,0,0,0,0,0}
     POOLED     04/01/99 117339 0   1.19   {124,46,0,0,0,0,0,0}
    ... and so on...

Thanks!

Irv

new topic     » goto parent     » topic index » view message » categorize

5. Re: Reading VB data

Irv Mullins wrote:

>>>I have some accounting data written with Visual Basic.
>>>The numbers are 8 bytes (reals, I guess).
>>>Can anyone tell me how to read these with Euphoria?
>>
>>With 8 bytes, my guess would be that they're float64 values. If that's
>>the case, read those 8 bytes into a sequence and use float64_to_atom()
>>to convert them into Euphoria values.
>
>Sounds like it would work, but all I got was 0.00 and -nan 's.
>Also tried reversing the sequence first, with worse results.
>Here's a snippet of the extracted data, along with the actual
>numbers typed in for comparison:
>                                Act.$    What Euphria reads:
>
>  JRUBBERCO  04/01/99 117329 1  21.84   {32,85,3,0,0,0,0,0}
>  JRUBBERCO  04/01/99 117329 0   1.32   {144,51,0,0,0,0,0,0}
>  CASH       04/01/99 117330 1   4.31   {92,168,0,0,0,0,0,0}
>  CASH       04/01/99 117330 0   0.26   {40,10,0,0,0,0,0,0}
>  CASH       04/01/99 117331 4 (56.66)  {184,90,247,255,255,255,255,255}
>  CASH       04/01/99 117331 0  (3.40)  {48,123,255,255,255,255,255,255}
>  JOHNSONEA  04/01/99 117332 1  40.38   {88,41,6,0,0,0,0,0}
>  JOHNSONEA  04/01/99 117332 0   2.43   {236,94,0,0,0,0,0,0}
>  CASH       04/01/99 117333 99  0.00   {0,0,0,0,0,0,0,0}
>  BENTTREEC  04/01/99 117334 1  16.17   {164,119,2,0,0,0,0,0}
>  BENTTREEC  04/01/99 117334 0   0.97   {228,37,0,0,0,0,0,0}
>  CHASTAINF  04/01/99 117335 1   8.88   {224,90,1,0,0,0,0,0}
>  CHASTAINF  04/01/99 117335 0   0.54   {24,21,0,0,0,0,0,0}
>  TRNRDAVID  04/01/99 117336 1   1.12   {192,43,0,0,0,0,0,0}
>  TRNRDAVID  04/01/99 117336 0   0.07   {188,2,0,0,0,0,0,0}
>  CLARKJIMMY 04/01/99 117337 1  24.15   {92,175,3,0,0,0,0,0}
>  CLARKJIMMY 04/01/99 117337 0   1.15   {236,44,0,0,0,0,0,0}
>  PICCOCOMM  04/01/99 117338 9  86.71   {28,59,13,0,0,0,0,0}
>  POOLED     04/01/99 117339 1  19.78   {168,4,3,0,0,0,0,0}
>  POOLED     04/01/99 117339 0   1.19   {124,46,0,0,0,0,0,0}
>  ... and so on...
>
>Sure would appreciate some help !

I think I've got it. Believe it or not, those are actually 64-bit signed
*integer* values. To get VB's dollar amount, divide the integer value by
10,000. Here's a quick solution which should work for dollar values in the
range abs(x) <= $214,748.3647:

 -----------
include machine.e

function VBfloat_to_atom(sequence s) -- our 8-byte sequence
 -- works for values in the range abs(x) <= 214,748.3647
atom x
   x = bytes_to_int(s[1..4]) -- ignore the last 4 bytes (quick fix)
   if x > #7FFFFFFF then
      -- handle negative value
      x = x - #100000000  -- power(2, 32)
   end if
   return x / 10000
end function
 -----------

I tested this routine for all of the above data, and the printed results
were 100% correct! :)


Be seeing you,
   Gabriel Boehme

new topic     » goto parent     » topic index » view message » categorize

6. Re: Reading VB data

On Mon, 24 May 1999, Boehme, Gabriel wrote:

> Irv Mullins wrote:
>
> >>>I have some accounting data written with Visual Basic.
> >>>The numbers are 8 bytes (reals, I guess).
> >>>Can anyone tell me how to read these with Euphoria?
> >Sure would appreciate some help !

<snip sample output>

> I think I've got it. Believe it or not, those are actually 64-bit signed
> *integer* values. To get VB's dollar amount, divide the integer value by
> 10,000. Here's a quick solution which should work for dollar values in the
> range abs(x) <= $214,748.3647:
>
>  -----------
> include machine.e
>
> function VBfloat_to_atom(sequence s) -- our 8-byte sequence
>  -- works for values in the range abs(x) <= 214,748.3647
> atom x
>    x = bytes_to_int(s[1..4]) -- ignore the last 4 bytes (quick fix)
>    if x > #7FFFFFFF then
>       -- handle negative value
>       x = x - #100000000  -- power(2, 32)
>    end if
>    return x / 10000
> end function
>  -----------
>
> I tested this routine for all of the above data, and the printed results
> were 100% correct! :)

Indeed it is! Thanks VERY much for the answer!

Regards,
Irv

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu