I hate giving up! I
think this works now. I thought if for-next loops don't like floats, then I'd do it with good old fashioned goto loops. You can see from the fact that the numbered labels are all over the place that I haven't used them much before.
The scale does change with the up and down arrows, but the fine lines only show in the correct places now if it is in base 10 - on account of the fact that I couldn't seem to make a# global - I tried dim a#(0) but it was still returning a divide by 0 error when it got to the function. The slider, though, still shows the correct value when the scale is altered because it's not using the log function.
I'm still not sure if this is along the lines of what you need, but I did learn a lot out of it nevertheless! (In particular, the fact that for some reason DBC doesn't like the number 4 as a goto label. 3's ok, so's 5 - but not 4 !!!)
sync on
a#=10.0
do
cls
xscale#=0
2:
line (xscale#)*100,200,(xscale#)*100,210
set cursor (xscale#)*100,210
ysc#=a#^xscale#
print int(ysc#)
finelines#=0
5:
line (log(abs(finelines#))*100)+(xscale#)*100,203,(log(abs(finelines#))*100)+(xscale#*100),205
finelines#=finelines#+1
if finelines#>=a# then goto 6
goto 5
6:
xscale#=xscale#+1
if xscale#>=5.0 then goto 3
goto 2
3:
ink rgb(255,0,0),0
box xslider#*100,190,(xslider#*100)+1,200
ink rgb(120,120,255),0
set cursor (xslider#*100)+10,180
ysl#=a#^xslider#
print int(ysl#)
if leftkey()=1 then xslider#=xslider#-0.01
if rightkey()=1 then xslider#=xslider#+0.01
if upkey()=1 then a#=a#+1
if a#>=2
if downkey()=1 then a#=a#-1
endif
set cursor 0,0
print "Logarithmic Slider - log to the base ",a#
print "Use left and right arrows to move slider."
print "Use up and down keys to change scale"
sync
loop
function log(answer#)
base#=10
log#=sqrt(answer#/base#)
lnb#=ln(base#)
lga#=base#^log#
repeat
log#=log#-((lga#-answer#)/(lga#*lnb#))
lga#=base#^log#
until abs(lga#-answer#)<=0.001
endfunction log#
function ln(answer#)
e#=2.71828
ln#=sqrt(answer#/e#)
lgn#=e#^ln#
repeat
ln#=ln#-((lgn#-answer#)/lgn#)
lgn#=e#^ln#
until abs(lgn#-answer#)<=0.001
endfunction ln#