Category : BASIC Source Code
Archive   : QBFAQR01.ZIP
Filename : DEC2ANY.BAS

 
Output of file : DEC2ANY.BAS contained in archive : QBFAQR01.ZIP
'Date: 01-22-92 (21:54)
'From: TOM HANLIN
'---------------------------------------------------------------------------
' just for the heck of it... the source for the PBClone 1.7 routine
' to convert a decimal number to any number base (2-35). Set Number$
' to STRING$(16, "0") on entry; use NumberLen to trim (via RIGHT$) on
' exit if you don't want any leading zeros. NumberLen = -1 on error.
DEFINT A-Z
SUB Dec2Any (DecimalNumber, NumberBase, Number$, NumberLen)
Num& = CVL(MKI$(DecimalNumber) + STRING$(2, 0))
Result$ = ""
IF NumberBase < 2 OR NumberBase > 35 THEN
NumberLen = -1
EXIT SUB
END IF
DO
NextNum& = Num& \ CLNG(NumberBase)
Digit = Num& - NextNum& * CLNG(NumberBase)
IF Digit < 10 THEN
Digit$ = CHR$(ASC("0") + Digit)
ELSE
Digit$ = CHR$(ASC("A") + Digit - 10)
END IF
Result$ = Digit$ + Result$
Num& = NextNum&
LOOP WHILE Num& > 0&
IF LEN(Result$) > LEN(Number$) THEN
NumberLen = -1
ELSE
NumberLen = LEN(Result$)
MID$(Number$, LEN(Number$) - NumberLen + 1) = Result$
END IF
END SUB


  3 Responses to “Category : BASIC Source Code
Archive   : QBFAQR01.ZIP
Filename : DEC2ANY.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/