Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
universal base conversion program possibly for a base conversion library later on
#11
Well my mr functions require a $ as in mr$( ) and they use variable length strings not fixed.

hmmm... where are those ", 1"  coming from? Looks like 4th arguement to Mr$
   
See the bottom error line that the exe is looking at.

Attempt to get red-line removed in Dragoncat code:
Code: (Select All)
' test Dragon by removal of fixed string in calls to Mr$

Dim dinpt, oput As String * 40
Dim dbase As String * 800
Dim dinput As String * 80
Dim dnum As String * 80
Dim whprt As String * 800
Dim fprt As String * 800
Dim gttl As String
Dim qmlt As String
Dim mlt As String
Dim zee As String
Dim sen As Long
Dim sign As Long
Dim ctr As Long
Dim flg As Long
Dim flg2 As Long
Dim lsplt As Long
Dim rsplt As Long
Dim pres As Long
Randomize Timer
Rem  $Dynamic
dinput = "000000000000"
Print "enter number to convert from incl.base use 4 digits for each digit include 0 in each of the 4 places thaat contains no value so 0 is 0000 and 1 is 0001 "
Print "first enter a base of at least 2 (0002) enter - for a negative number . for decimal point"
Input ": "; dinput
Print " in a similiar manner enter the base to convert too "
Input ": "; oput
sen = Len(dinput)
dbase = Left$(dinput, 4)
sen = sen - 4
dnum = Right$(dinput, sen)
sign = 1
sen = Len(dnum)
If Left$(dnum, 1) = "-" Then
    sign = -1
    sen = sen - 1
    dnum = Right$(dnum, sen)
End If
ctr = 1
flg = 0
flg2 = 0
While flg = 0 And ctr <= sen
    If Mid$(dnum, ctr, 1) = "." Then
        lsplt = ctr - 1
        rsplt = sen - ctr
        flg = 1
        If ctr = 1 Then flg2 = 1
    End If
    ctr = ctr + 1
Wend
If flg = 1 And flg2 = 0 Then
    whprt = Left$(dnum, lsplt)
    fprt = Right$(dnum, rsplt)
End If
If flg = 1 And flg2 = 1 Then
    whprt = "0000"
    fprt = Right$(dnum, rsplt)
    lsplt = 4
End If
gttl = "0"
qmlt = "1"
mlt = dbase
If flg = 0 Then whprt = dnum
While lsplt > 0
    zee = Right$(whprt, 4)
    gttl = Mr$(gttl, "+", Mr$(zee,"*", qmlt))
    qmlt = mr$(qmlt, "*", mlt)
    lsplt = lsplt - 4
    whprt = Left$(whprt, lsplt)
Wend
pres = Int((Log(Val(dbase)) * Int(rsplt / 4)) / Log(Val(oput)))
qmlt = "1"
Rem  wqs&& = 1 to pres&&
qmlt = mr(qmlt, "/", dbase)
While rsplt >= 4
    zee = Left$(fprt, 4)
    gttl = mr(gttl, "+", mr(zee, "*", qmlt))
    qmlt = mr(qmlt, "/", dbase)
    rsplt = rsplt - 4
    fprt = Right$(fprt, rsplt)
Wend
Print "base ten value: "; gttl

$include: 'StringMath.bm'
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
RE: universal base conversion program possibly for a base conversion library later on - by bplus - 04-18-2025, 12:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Keyhit to Inkey Conversion Project Pete 7 593 01-11-2026, 01:26 AM
Last Post: Pete
  QB UI Library aadityap0901 6 1,185 08-02-2025, 05:13 PM
Last Post: aadityap0901
  new approach to base conversion system and math library Dragoncat 2 577 07-16-2025, 10:19 PM
Last Post: Dragoncat
  Everything Date Library in progress SMcNeill 2 718 05-14-2025, 08:36 PM
Last Post: SMcNeill
  Angle, Vector, Radian, and Distance Library TerryRitchie 11 2,754 03-31-2025, 10:16 PM
Last Post: Dragoncat

Forum Jump:


Users browsing this thread: 1 Guest(s)