Category : Miscellaneous Language Source Code
Archive   : TIPI.ZIP
Filename : ANYBASE.TPI

 
Output of file : ANYBASE.TPI contained in archive : TIPI.ZIP
# ANYBASE.TPI
# by Kent Peterson 10/24/93

defstr digit$
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
digit$ store

defvar frombase
defvar tobase
defstr numin$

define ** ( x y -- x**y )
# raises x to the y power
# Note: only works with non-negative
# y values
dup
case 0 of drop drop 1 endof
1 of drop endof
default
over swap
1 - do over * loop
swap drop
endcase
enddef

begin
"Convert number" print$
get$ ucase$ dup$ numin$ store
"" =$ if bye endif
"from base" print$
getnum frombase store
"to base" print$
getnum tobase store

# Convert the number to base 10
0
numin$ fetch len drop$
do
digit$ fetch
index 1 numin$ fetch mid$
instr 1 -
drop$ drop$
numin$ fetch len drop$
index - frombase fetch swap **
dup 0 = if drop 1 endif
* +
loop

# Convert the number from base 10
# to the target base
""
begin
dup tobase fetch mod
1 + digit$ fetch 1 mid$ swap$ +$
tobase fetch / dup not
until drop

print$ cr
0 until


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : TIPI.ZIP
Filename : ANYBASE.TPI

  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/