Microsoft Small Basic

Program Listing: TCZ203

Sentences_Sample()
Show_Sample()
data()
Controls.ButtonClicked=onbuttonclick


Sub morse
For k=1 To (N1+N2)
Shapes.Remove(s1n[k])
Shapes.Remove(s2n[k])
Shapes.Remove(sc[k])
EndFor
ddx=0
For i=1 To Text.GetLength(dm)
c=text.GetSubText(dm,i,1) ' get 1 word
sc[i]=shapes.AddText(c)
Shapes.Animate(sc[i],35+8*(ddx),405+10*i,500) ' show word
c1=text.ConvertToUpperCase(c) '
cn=text.GetCharacterCode(c1) ' get upper code number
If cn=32 Then ' space
Goto end1
EndIf
cl=Text.GetLength(d[cn])
dx=0
For j=1 To cl
If Text.GetSubText(d[cn],j,1)=1 Then ' circle
N1=N1+1
s1n[N1]=Shapes.AddEllipse(8,8)
Shapes.Animate(s1n[N1],40+j*8+8*(dx+ddx),400+10*i,500)
Elseif Text.GetSubText(d[cn],j,1)=2 Then ' rectangle
N2=N2+1
s2n[N2]=Shapes.AddRectangle(16,8)
Shapes.Animate(s2n[N2],40+j*8+8*(dx+ddx),400+10*i,500)
dx=dX+1 ' rectangle is double wide
elseif Text.GetSubText(d[cn],j,1)=0 Then ' space
EndIf
EndFor
ddx=ddx+cl+dx+1 ' position moving add one space
Goto end2
end1:
ddx=ddx+3 ' add three spaces
end2:
EndFor
EndSub

sub onbuttonclick
name=controls.LastClickedButton 'Last button name
nm=controls.GetButtonCaption(name) ' Button's caption
If nm="EXE" Then
dm=controls.GetTextBoxText(textbox[1])
Else
dm=nm
EndIf
Morse() ' show Morse signal
EndSub

Sub Show_Sample
GraphicsWindow.Clear()
GraphicsWindow.Title="Morse Signal"
GraphicsWindow.BackgroundColor="Lightcyan"
GraphicsWindow.left=50
GraphicsWindow.top=0
GraphicsWindow.Height=700
GraphicsWindow.Width=1250
GraphicsWindow.FontName="Coorie new"
GraphicsWindow.Show()
GraphicsWindow.FontItalic="True"
GraphicsWindow.FontSize=25
GraphicsWindow.BrushColor="Navy"
GraphicsWindow.DrawText(50,10,Sample[10])
GraphicsWindow.FontSize=18
GraphicsWindow.BrushColor="Red"
For i=1 To 5
btn[i]=Controls.AddButton(Sample[i],50,50*i) ' show sample
Controls.SetSize(btn[i],1000,40)
EndFor
textbox[1] = Controls.AddTextBox(50,350) ' textbox
Controls.SetSize(textbox[1] ,1000,40)
btn[6]=Controls.AddButton("EXE",1060,350) ' button
Controls.SetSize(btn[i],50,40)
Endsub

Sub data
d[48+0]="202020202" ' 0
d[48+1]="102020202" ' 1
d[48+2]="101020202" ' 2
d[48+3]="101010202" ' 3
d[48+4]="101010102" ' 4
d[48+5]="101010101" ' 5
d[48+6]="201010101" ' 6
d[48+7]="202010101" ' 7
d[48+8]="202020101" ' 8
d[48+9]="202020201" ' 9
'
d[64+1]="102" ' A
d[64+2]="2010101" ' B
d[64+3]="2010201" ' C
d[64+4]="20101" ' D
d[64+5]="1" ' E
d[64+6]="1010201" ' F
d[64+7]="20201" ' G
d[64+8]="1010101" ' H
d[64+9]="101" ' I
d[64+10]="1020202" ' J
d[64+11]="20102" ' K
d[64+12]="1020101" ' L
d[64+13]="202" ' M
d[64+14]="201" ' N
d[64+15]="20202" ' O
d[64+16]="1020201" ' P
d[64+17]="2020102" ' Q
d[64+18]="10201" ' R
d[64+19]="10101" ' S
d[64+20]="2" ' T
d[64+21]="10102" ' U
d[64+22]="1010102" ' V
d[64+23]="10202" ' W
d[64+24]="2010102" ' X
d[64+25]="2010202" ' Y
d[64+26]="2020101" ' Z
EndSub

Sub Sentences_Sample
' These samples ( Sample[1] -Sample[4] ) are written in MSN.UK head news. (2011/10/04 )
Sample[1]="Nobel officials dilemma"
Sample[2]="PM seems to think jogging"
Sample[3]="Rihanna defends her image"
Sample[4]="AK is due to fly home"
Sample[5]="123 456 78 9 0"
Sample[10]="Select a sample sentences or input your sentences in textbox and click EXE button "
EndSub