Bay Six Software
Beyond the Basics

Author Message
Petrus
Junior Member

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

 Posted: Oct 8th, 2014, 5:55pm    Post subject: How to convert MBF strings to thier respected ieee Decimal f 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.
Brent

Joined: 01 Jul 2005
Posts: 732

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

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
Petrus
Junior Member

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

 Posted: Oct 10th, 2014, 4:41pm    Post subject: Re: How to convert MBF strings to thier respected ieee Decimal f Hi, Runs perfectly !!!! you're great !!!! Thank you very much !!! Beer for everyone, Cheers !!!
Petrus
Junior Member

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

 Posted: Oct 10th, 2014, 4:46pm    Post subject: Re: How to convert MBF strings to thier respected ieee Decimal f 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
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT Page 1 of 1
 Jump to: Select a forumAnnouncements & RulesThe ClubhouseViviFire language-- ViviFire DocumentationSnippet TestingSapientBoardCode OptimizationInternet ProgrammingInclusive DesignVFScriptWMLiberty DLL-- WMLiberty Demos & TutorialsBay6ZipLB for MS-DOS BASIC UsersArea 5+1General DiscussionsViviFire Archive-- VF Dev & Testing ArchiveGeneral Category Archive
 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