Advertisement
AHobbyistProgrammer

Morse Code

May 19th, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a := 139 ; 1 indicates a dot, 3 indicates a dash, 9 indicates the end of the character.
  2. b := 31119
  3. c := 31319
  4. d := 3119
  5. e := 19
  6. f := 11319
  7. g := 3319
  8. h := 11119
  9. i := 119
  10. j := 13339
  11. k := 3139
  12. l := 13119
  13. m := 339
  14. n := 319
  15. o := 3339
  16. p := 13319
  17. q := 33139
  18. r := 1319
  19. s := 1119
  20. t := 39
  21. u := 1139
  22. v := 11139
  23. w := 1339
  24. x := 31139
  25. y := 31339
  26. z := 33119
  27.  
  28. dot := 180 ; This is the length of the base unit. Increasing the number increases the time it takes for a message to play.
  29. dash := dot * 3
  30. shpace := dot * 4 ; misspelled since space normally means something on its own
  31.  
  32. F2:: ; takes message, converts to numbers which represent dots, dashes and spaces.
  33.     InputBox, message
  34.     message := RegExReplace(message, " ", 4)
  35.     StringSplit, letter, message
  36.     Loop, %letter0%
  37.     {
  38.         pseudo_array_element := letter%A_index%
  39.         contents_of_pseudo_array_element := %pseudo_array_element%
  40.         number_string = %number_string%%pseudo_array_element%
  41.     }
  42.     return
  43.  
  44. f3:: ; uses previously created string of numbers, loops to create the appropriate flash length for each number as it goes through the string.
  45.     StringSplit, dotdash, number_string
  46.     loop, %dotdash0%
  47.     {
  48.         if dotdash%a_index% = 1
  49.         {
  50.             Gui, Show, w479 h379, dot
  51.             Sleep, dot
  52.             Gui Destroy
  53.             Sleep, dot
  54.         }
  55.         if dotdash%a_index% = 3
  56.         {
  57.             Gui, Show, w479 h379, dash
  58.             Sleep, dash
  59.             Gui Destroy
  60.             Sleep, dot
  61.         }
  62.         if dotdash%a_index% = 4
  63.         {
  64.             Sleep, shpace
  65.         }
  66.         if dotdash%a_index% = 9
  67.         {
  68.             Sleep, dash
  69.         }
  70.     }
  71.     return
  72.  
  73.  
  74. {#IfWinActive, ahk_exe SciTE.exe
  75. ~^s::Reload
  76. #p::Pause
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement