In this tutorial we will write several morse tests that generate 5 common random words - play them at our desired speed - and test our morse copying accuracy.

Test letter-by-letter

First you will be tested against five generated words on a letter-by-letter basis. (don’t forget to type a space at the end of the word). Create the CW script five-common-words.rb (shown below) in a text editor, or download via the link and save as five_common_words.rb:

  # five-common-words.rb

require 'cw'

cw do
  comment "5 very common words at 12 words per minute"
  shuffle
  word_count 5
  wpm 12
end


Run the script

To run the test with the following:


cw five_common_words

Details of how to adjust colours are available here.

Test word-by-word

Instead of testing letter-by-letter, you may also test word-by-word. Simply add the command test_words to the end of the test and you will be marked against completed words. In word-by-word mode any incorrect letter within the word will mean the whole word is marked wrong!

  # five_common_words_2.rb

require 'cw'

cw do
  comment "5 common words at 12 words per minute"
  shuffle
  wpm        12
  word_count 5
  test_words    # add the command test_words here
end


Combine both examples

Here we will combine both examples into a single script. In practice you may end up having CW scripts comprising of many tests (perhaps a script called daily.rb or morning.rb). Create or download the combined CW script (or download it) and run it.

  # five_common_words_3.rb

require 'cw'

cw do
  comment "5 common words at 12 wpm (test letters)"
  shuffle
  wpm        12
  word_count 5
end

cw do
  comment "5 common words at 12 wpm (test words)"
  shuffle
  wpm        12
  word_count 5
  test_words
end


Repeat until correct

The repeat_word command causes the test to be repeated until the word is entered correctly. This is useful when trying higher speed recognition of words.

  # five-common-words-4.rb

require 'cw'

cw do
  comment "5 common words at 12 wpm"
  shuffle
  wpm        12
  word_count 5
  repeat_word
end


Example with just word_count

Remove all commands apart from word_count and see what happens.

  # five_common_words_5.rb

require 'cw'

cw do
  word_count 5
end