Category : Utilities for DOS and Windows Machines
Archive   : 4DTNT.ZIP
Filename : BUMP.BTM

 
Output of file : BUMP.BTM contained in archive : 4DTNT.ZIP
if "%1" == "" .or. "%2" == "" .or. "%[%2]" == "" goto help
set $foo=%@upper[%1]
set $wstr=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ

iff %$foo = A then ^ gosub alpha
elseiff %$foo = B then ^ gosub binary
elseiff %$foo = O then ^ gosub octal
elseiff %$foo = H then ^ gosub hex
elseiff %$foo = D then ^ gosub dec
elseiff %$foo = N then ^ gosub an
elseiff %$foo gt 1 .and. %$foo lt 37 then ^ gosub base
else goto help
endiff

iff %$val ne 0 then^unset %2 ^ gosub cleanup ^ goto helpval
else set %2=%$foo ^gosub cleanup^quit 0
endiff
quit

:cleanup
rem unset $foo $wstr $val $max >& nul
return

:alpha
set $max=25
set $wstr=%@substr[%$wstr,10,26]
gosub bumpit
return

:binary
set $max=1
gosub bumpit
return

:octal
set $max=7
gosub bumpit
return

:hex
set $max=15
gosub bumpit
return

:dec
set $max=9
gosub bumpit
return

:an
set $max=35
gosub bumpit
return

:base
set $max=%@eval[%$foo-1]
gosub bumpit
return

:bumpit
gosub validate
if %$val ne 0 return
set $foo=%@upper[%[%2]]
set $i=%@len[%$foo]
set $j=%@eval[%$i-1]
set $k=%$j
:bumploop
set $front=
if %$j gt 0 set $front=%@substr[%$foo,0,%$j]
set $targ=%@substr[%$foo,%$j,1]
set $rear=
if %$j lt %$k set $rear=%@substr[%$foo,%@eval[%$j+1],%@eval[%$k-%$j]]
set $l=%@index[%$wstr,%$targ]
iff %$l lt %$max then ^ set $targ=%@substr[%$wstr,%@eval[%$l+1],1]^set $j=0
else set $targ=%@substr[%$wstr,0,1]
endiff
set $foo=%[$front]%[$targ]%[$rear]
if %$j gt 0 (set $j=%@eval[%$j-1]^goto bumploop)
rem unset $i $j $k $l $front $rear $targ >& nul
return

:validate
set $i=0
:valloop
set $val=%@index[%$wstr,%@substr[%[%2],%$i,1]]
if %$val lt 0 .or. %$val gt %$max (set $val=%$max^return)
set $i=%@eval[%$i+1]
iff %$i lt %@len[%[%2]] then ^ goto valloop
else set $val=0^return
endiff
return

:helpval
echo Invalid character detected.
echo .
goto help

:help
echo Usage BUMP mode var
echo  
echo ! !
echo ! Any environment variable of the correct type
echo A=alpha [A-Z]
echo B=binary [0-1]
echo D=decimal [0-9]
echo H=hex [0-F]
echo N=alph/num [0-9,A-F]
echo O=octal [0-7]
echo [2-36] [0-(n-1)]
echo New value returned in var
echo Carry propagates left, overflow is ignored
quit 4


  3 Responses to “Category : Utilities for DOS and Windows Machines
Archive   : 4DTNT.ZIP
Filename : BUMP.BTM

  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/