BTW, you don't have to limit yourself. You can do your own project like this, and substitute Klingon alphabet, for example. Do you know that Small Basic uses Unicode? Try looping some big numbers through Text.GetCharacter and you'll get the idea.
Of course, as luck would have it, I still have some time, so I improved it with tones. I think there is something wrong here because the sound is so soft! Oh, well.
'Extending the code, as well as decoding is left as an exercise for the reader!
Morse="a=+-;b=-+++;c=-+-+;d=-++;e=+;f=++-+;g=--+;h=++++;i=++;j=+---;k=-+-;l=+-++;m=--;n=-+;o=---;p=+--+;q=--+-;r=+-+;s=+++;t=-;u=++-;v=+++-;w=+--;x=-++-;y=-+--;z=--++;"
Loop:
TextWindow.Write("Enter Text:")
t=TextWindow.Read()
For i=1 To Text.GetLength(t)
TextWindow.Write((Morse[Text.ConvertToLowerCase(Text.GetSubText(t,i,1))])+" ")
EndFor
TextWindow.WriteLine(" ")
Goto Loop
'Extending the code, as well as decoding is left as an exercise for the reader!
Morse="a=+-;b=-+++;c=-+-+;d=-++;e=+;f=++-+;g=--+;h=++++;i=++;j=+---;k=-+-;l=+-++;m=--;n=-+;o=---;p=+--+;q=--+-;r=+-+;s=+++;t=-;u=++-;v=+++-;w=+--;x=-++-;y=-+--;z=--++;"
TextWindow.WriteLine("Morse Code Encoder by Harry Hardjono")
Loop:
TextWindow.Write(Text.GetCharacter(13)+Text.GetCharacter(10)+"Enter Text:")
t=TextWindow.Read()
For i=1 To Text.GetLength(t)
MC=Text.Append(MC,(Morse[Text.ConvertToLowerCase(Text.GetSubText(t,i,1))]+" ")) 'Comment this out for no sound
TextWindow.Write((Morse[Text.ConvertToLowerCase(Text.GetSubText(t,i,1))])+" ")
EndFor
PlayMorse() 'Comment this out for no sound
Goto Loop
Sub PlayMorse
TT="+=C12;-=C4; =P4;"
For j=1 To Text.GetLength(MC)
MT=Text.Append(MT,TT[Text.GetSubText(MC,j,1)])
EndFor
Sound.PlayMusic(MT)
MC=""
MT=""
EndSub
No comments:
Post a Comment