Bay Six Software Forum Index Bay Six Software
Beyond the Basics
 
 FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to convert MBF strings to thier respected ieee Decimal f

 
Post new topic   Reply to topic    Bay Six Software Forum Index -> LB for MS-DOS BASIC Users
View previous topic :: View next topic  
Author Message
Petrus
Junior Member


Joined: 12 Jul 2014
Posts: 13
Location: Barcelona - Spain

PostPosted: Oct 8th, 2014, 5:55pm    Post subject: How to convert MBF strings to thier respected ieee Decimal f Reply with quote

I wrote an accounting package back in the late 80's, early 90's that began back with Qbasic. All the Data that was saved to random accessed files using the old unsupported Microsoft Binary Format (MBF). 10 years later the firm now wants me to develop a LIBERTY BASIC version of the software. I've come to a snag in development right from the start where LB no longer supports the MBF format. There are 3 function I need, they are CVI (integer), CVS (single), CVD (Double), these convert MBF strings to thier respected ieee Decimal format. I've been searching the net for about a week trying to find a method to do this and have come up against a brick wall. if anyone is able to assist me in my problem please feel free to add your advice. Anything is better than what I've come up with so far.
Back to top
View user's profile Send private message Send e-mail
Brent
Site Admin


Joined: 01 Jul 2005
Posts: 798

PostPosted: Oct 9th, 2014, 6:37pm    Post subject: Re: How to convert MBF strings to thier respected ieee Decimal f Reply with quote

I googled "function cvdmbf" and came up with several results. I chose one and translated it into LB. However, since I don't have an easy way to test it, the following code is untested. Please let me know if it works.
Code:
Function CVDMBF(number$)
    On Error GoTo [error]
    CVDMBF = 0
    If Len(number$) = 8 And number$ <> Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0) Then
        exponent = Asc(Right$(number$, 1)) - 128
        mantissa = Asc(Mid$(number$, 7, 1))
        sign = Int(mantissa / 128)
        mantissa = 128 + mantissa Mod 128
        CVDMBF = mantissa / 256
        For byte = 6 To 1 Step -1
            CVDMBF = CVDMBF + Asc(Mid$(number$, byte, 1)) / 256 ^ (8 - byte)
        Next byte
        CVDMBF = CVDMBF * 2 ^ exponent
        If sign Then CVDMBF = -1*CVDMBF
    End If
    Exit Function
[error]
    Notice "Unexpected error "; Err; " in CVDMBF"
End Function

EDIT: Fixed missing parens.

_________________
Brent


Last edited by Brent on Oct 10th, 2014, 8:43pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Petrus
Junior Member


Joined: 12 Jul 2014
Posts: 13
Location: Barcelona - Spain

PostPosted: Oct 10th, 2014, 4:41pm    Post subject: Re: How to convert MBF strings to thier respected ieee Decimal f Reply with quote

Hi,

Runs perfectly !!!!
you're great !!!!

Thank you very much !!!

Beer for everyone, Cheers !!!
Back to top
View user's profile Send private message Send e-mail
Petrus
Junior Member


Joined: 12 Jul 2014
Posts: 13
Location: Barcelona - Spain

PostPosted: Oct 10th, 2014, 4:46pm    Post subject: Re: How to convert MBF strings to thier respected ieee Decimal f Reply with quote

Just missing the parenthesis...


Function CVDMBF(number$)
On Error GoTo [error]
CVDMBF = 0
If Len(number$) = 8 And number$ <> Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0)+Chr$(0) Then
exponent = Asc(Right$(number$, 1)) - 128
mantissa = Asc(Mid$(number$, 7, 1))
sign = Int(mantissa / 128)
mantissa = 128 + mantissa Mod 128
CVDMBF = mantissa / 256
For byte = 6 To 1 Step -1
CVDMBF = CVDMBF + Asc(Mid$(number$, byte, 1)) / 256 ^ (8 - byte)
Next byte
CVDMBF = CVDMBF * 2 ^ exponent
If sign Then CVDMBF = -1*CVDMBF
End If
Exit Function
[error]
Notice "Unexpected error "; Err; " in CVDMBF"
End Function
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Bay Six Software Forum Index -> LB for MS-DOS BASIC Users All times are GMT
Page 1 of 1
Jump to:  
Quick Reply
Username:
Message:
   Shortcut keys: Alt+Q to activate, Alt+P to preview, Alt+S to submit
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Lo-Fi Version
Powered by phpBB © 2001, 2005 phpBB Group