Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
55
Task/Morse-code/Liberty-BASIC/morse-code.basic
Normal file
55
Task/Morse-code/Liberty-BASIC/morse-code.basic
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
'The following code relies on the Windows API
|
||||
Input "Input the text to translate to Morse Code... "; string$
|
||||
Print PlayMorse$(string$)
|
||||
End
|
||||
|
||||
Function PlayMorse$(string$)
|
||||
'LetterGap = (3 * BaseTime)
|
||||
'WordGap = (7 * BaseTime)
|
||||
BaseTime = 50
|
||||
freq = 1250
|
||||
PlayMorse$ = TranslateToMorse$(string$)
|
||||
morseCode$ = "./-"
|
||||
For i = 1 To Len(PlayMorse$)
|
||||
Scan
|
||||
dwDuration = (Instr(morseCode$, Mid$(PlayMorse$, i, 1)) * BaseTime)
|
||||
If (Mid$(PlayMorse$, i, 1) <> " ") Then
|
||||
CallDLL #kernel32, "Beep", freq As ulong, dwDuration As ulong, ret As long
|
||||
CallDLL #kernel32, "Sleep", BaseTime As long, ret As void
|
||||
End If
|
||||
If (Mid$(PlayMorse$, i, 1) <> " ") Then
|
||||
sleep = (3 * BaseTime)
|
||||
Else
|
||||
sleep = (7 * BaseTime)
|
||||
End If
|
||||
CallDLL #kernel32, "Sleep", sleep As long, ret As void
|
||||
Next i
|
||||
End Function
|
||||
|
||||
Function TranslateToMorse$(string$)
|
||||
string$ = Upper$(string$)
|
||||
For i = 1 To Len(string$)
|
||||
While desc$ <> "End"
|
||||
Read desc$, value$
|
||||
If desc$ = "" Then desc$ = chr$(34)
|
||||
If desc$ = Mid$(string$, i, 1) Then
|
||||
If Mid$(string$, i, 1) <> " " Then value$ = " " + value$
|
||||
TranslateToMorse$ = TranslateToMorse$ + value$
|
||||
Exit While
|
||||
End If
|
||||
Wend
|
||||
If desc$ = "End" Then Notice Mid$(string$, i, 1) + " is not accounted for in the Morse Code Table."
|
||||
Restore
|
||||
Next i
|
||||
TranslateToMorse$ = Trim$(TranslateToMorse$)
|
||||
Data "A", ".-", "B", "-...", "C", "-.-.", "D", "-..", "E", ".", "F", "..-.", "G", "--."
|
||||
Data "H", "....", "I", "..", "J", ".---", "K", "-.-", "L", ".-..", "M", "--", "N", "-."
|
||||
Data "O", "---", "P", ".--.", "Q", "--.-", "R", ".-.", "S", "...", "T", "-", "U", "..-"
|
||||
Data "V", "...-", "W", ".--", "X", "-..-", "Y", "-.--", "Z", "--..", "Á", "--.-", "Ä", ".-.-"
|
||||
Data "É", "..-..", "Ñ", "--.--", "Ö", "---.", "Ü", "..--", "1", ".----", "2", "..---"
|
||||
Data "3", "...--", "4", "....-", "5", ".....", "6", "-....", "7", "--...", "8", "---.."
|
||||
Data "9", "----.", "0", "-----", ",", "--..--", ".", ".-.-.-", "?", "..--..", ";", "-.-.-"
|
||||
Data ":", "---...", "/", "-..-.", "-", "-....-", "'", ".----.", "+", ".-.-.", "", ".-..-."
|
||||
Data "@", ".--.-.", "(", "-.--.", ")", "-.--.-", "_", "..--.-", "$", "...-..-", "&", ".-..."
|
||||
Data "=", "-...-", "!", "..--.", " ", " ", "End", ""
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue