Microsoft Small Basic

Program Listing: ZBF621-0
For x=1 To 20
hh[x]=Shapes.AddRectangle(12,24)
aa=150-x*6
Shapes.Rotate (hh[x],55-x*5.7)
Shapes.Move (hh[x],300+ldmath.cos(aa)*200,200+LDMath.Sin(aa)*200)
ll[x]=Shapes.AddLine( LDShapes.GetLeft(hh[x])+5, LDShapes.GetTop(hh[x])+5,300,250)
rr=LDMath.Convert2Radial (LDShapes.GetLeft(hh[x])+5, LDShapes.GetTop(hh[x])+5,300,250)
qq[x]=LDMath.Convert2Cartesian (LDShapes.GetLeft(hh[x])+5, LDShapes.GetTop(hh[x])+5,70,rr[2])
ll1[x]=Shapes.AddLine( qq[x][1],qq[x][2],300,250)
endfor
mm=Shapes.AddRectangle(12,24)
Shapes.SetOpacity (mm,4)
LDShapes .Move(mm,295,208)
LDShapes.ZIndex (mm,11111)
LDUtilities.ShowNoShapeErrors="False
LDUtilities.ShowErrors="False
GraphicsWindow.BackgroundColor ="Gray
pp=Shapes.AddRectangle(500,50)
Shapes.Move (pp,290,200)
LDShapes.PenWidth(pp,0)
LDShapes.BrushColour (pp,"Beige")
GraphicsWindow.FontName="Lucida console
GraphicsWindow.Title="Typewriter v0.1"
GraphicsWindow.FontSize =14
GraphicsWindow.KeyDown=kkk
GraphicsWindow.KeyUp=kuu
cc=1
inn=0
s10=9
nxt=1
done=0
cp[1]="qwertyuiop1234567890"
cp[2]="asdfghjklzxcvbnm,.+-"
Sub kuu
If nn>0 Then
'ee =SPStopWatch.ElapsedMilliseconds
ee=Clock.ElapsedMilliseconds-el
If done=1 then
ldfastShapes.SetOpacity (ftxs[f-1],10+90*ee/150)
done=0
Shapes.showShape(hh[nn])
Shapes.showShape(ll[nn])

Shapes.SetOpacity (mm,4)
Shapes.Remove(qx)
endif
endif
nxt=1
lk=GraphicsWindow.LastKey
If lk="LeftShift" Or lk="RightShift" Then
isShiftPressed = "False"
EndIf
EndSub

Sub kkk
lk= GraphicsWindow.LastKey
' GraphicsWindow.Title =lk
If lk="Space" Then
lk=" "
elseIf lk="Back" and LDShapes.GetLeft(pp)<290 Then
For f=1 To cc
LDFastShapes.Move(ftxs[f],LDfastShapes.GetLeft (ftxs[f])+s10,LDfastShapes.GetTop (ftxs[f]))
EndFor
Shapes.Move(pp, LDShapes.GetLeft(pp)+s10,LDShapes.GetTop(pp))


LDFastShapes.Update ()
elseIf lk="OemPeriod" Then
lk="."
elseIf lk="OemComma" Then
lk=","

ElseIf lk="LeftShift" Or lk="RightShift" Then
isShiftPressed = "True"
elseIf Text.GetLength (lk)=2 Then
lk=text.GetSubTextToEnd (lk,2)
elseIf Text.StartsWith (lk,"NumP") then
lk=text.GetSubTextToEnd (lk,7)
endif
If lk=1 Then
lk="l"
ElseIf lk=0 then
lk="o"
endif

If Text.GetLength(lk)=1 and inn=0 and nxt=1 Then
inn=1
nxt=0
lc=Text.ConvertToLowerCase (lk)
nn=text.GetIndexOf (cp[1],lc)
If nn=0 Then
nn=text.GetIndexOf (cp[2],lc)
EndIf
If nn>0 Then


Shapes.HideShape(hh[nn])
Shapes.HideShape(ll[nn])
qx=Shapes.AddLine (qq[nn][1],qq[nn][2],300,220)
endif
Shapes.SetOpacity (mm,100)
'SPStopWatch.ResetStopWatch ()
'SPStopWatch.StartStopWatch()
el=Clock.ElapsedMilliseconds
txt=txt+lk
txs[cc]=shapes.AddText(Text.ConvertToLowerCase(lk))
LDShapes.ZIndex (txs[cc],Text.GetLength (txt)+10)
ftxs[cc]=LDFastShapes.ShapeIndex(txs[cc])
LDFastShapes .Move(ftxs[cc],295,208+Math.GetRandomNumber(2))
'if FCKeyboard.IsShiftPressed Then
If isShiftPressed Then
Shapes.SetText(txs[cc],lk)
endif
if LDShapes.GetLeft(pp)>-195 then
For f=1 To cc
LDFastShapes.Move(ftxs[f],LDfastShapes.GetLeft (ftxs[f])-s10,LDfastShapes.GetTop (ftxs[f]))
EndFor
Shapes.Move(pp, LDShapes.GetLeft(pp)-s10,LDShapes.GetTop(pp))

endif
LDFastShapes.Update ()
cc=cc+1
inn=0
done=1
ElseIf lk="Return" and inn=0 then
inn=1
nxt=1
sp=Shapes.GetLeft(pp)
For f=1 To cc-1
LDFastShapes.Move(ftxs[f],290+math.abs(sp-LDFastShapes.GetLeft (ftxs[f])),LDFastShapes.GetTop (ftxs[f])-20)
EndFor
LDFastShapes.Update ()
Shapes.Move (pp,290,Shapes.GetTop (pp)-30)
LDShapes.SetSize (pp,500,ldShapes.Height(pp)+30)
inn=0
endif
EndSub