Microsoft Small Basic

Program Listing: LXM256
boxwid = 200
boxhei = 20
boxpx = 100
boxpy = 30
textpy = 70
textpx = 40
tx = 50
ty = 150
GraphicsWindow.Title = "Password controls"
GraphicsWindow.BackgroundColor = "Gainsboro"
GraphicsWindow.MouseDown = Click
GraphicsWindow.BrushColor = "silver"
GraphicsWindow.fillRectangle(boxpx,boxpy,boxwid,boxhei)
GraphicsWindow.DrawRectangle(boxpx,boxpy,boxwid,boxhei)
GraphicsWindow.BrushColor = "GRAY"
GraphicsWindow.DrawText(boxpx-80,boxpy+3,"PASSWORD:")
GraphicsWindow.BrushColor = "BLACK"
GraphicsWindow.DrawText(textpx,textpy,"1. Click in the box to type password")
GraphicsWindow.DrawText(textpx,textpy+15,"2. Hit return and password is entered")
Sub Click
mx = GraphicsWindow.MouseX
my = GraphicsWindow.Mousey
If mx > boxpx And mx < (boxpx+boxwid) Then
If my >boxpy And my < (boxpy+boxhei) Then
entry()
Else
null()
EndIf
Else
null()
EndIf
EndSub
Sub entry
GraphicsWindow.KeyDown = Key
LINE = Shapes.AddLine(boxpx+10,boxpy+3,boxpx+10,boxpy+15)
EndSub
Sub Key
New = GraphicsWindow.LastKey
If New = "Back" Then
Shapes.Remove(circ[pass])
lend = Text.GetLength(string)
string = Text.GetSubText(string,1,lend-1)
Shapes.Move(LINE,(16*PASS)-16,0)
pass = pass -1
Else
If New = "Return" Then
password=string
For i = 0 To pass
Shapes.Remove(circ[i])
EndFor
Shapes.Remove(line)
pass=0
string=""
GraphicsWindow.DrawText(tx,ty," Password : "+password)
ty = ty + 20
Else
pass = pass + 1
circ[pass]=Shapes.AddEllipse(12,12)
Shapes.Move(LINE,16*PASS,0)
Shapes.Move(circ[pass],boxpx-10+(pass*16),boxpy+3)
String = String+New
EndIf
EndIf
EndSub
Sub off
GraphicsWindow.KeyDown = null
EndSub
Sub null
Shapes.Remove(line)
off()
EndSub