3 min read

1. Triggers and inputs

Triggers start shortcuts, while inputs collect the performer’s information and often act as a trigger. So, it made sense to group both together.

Text input

This is the primary input method offered by Apple itself.

Input Playing Card

The quickest way to enter a playing card is as digits. It’s easier and faster to enter digits from a number pad than to find an a, j, q, or k on a tiny on-screen keyboard.

The first one or two digits entered will be the card value, and the final digit will be the suit, according to CHaSeD:

1 - clubs
2 - hearts
3 - spades, and
4 - diamonds

Shortcuts

Download the Input Playing Card shortcut.

This shortcut takes in a number and converts it to the alphanumeric for the card. For example:

  • 11 becomes ac
  • 84 becomes 8d
  • 113 becomes js, and
  • 122 becomes qh
How it works

The first step is to count the characters to see if there are 2 or 3. Note that there is no error checking. This is common with shortcuts, where the user is assumed to know what to enter.

If there are two characters, the match pattern is set as one digit followed by another. Otherwise, it is set as two digits followed by a single digit.

Next, the routine collects the matching digits and uses them to collect the appropriate value and suit from the two lists representing values and suits.

Finally, the value and suit are combined to provide the complete card.

If you want to output the full card name, e.g. ace of clubs, update the value and suit lists, then modify the final text block.

  1. Ask for Input
    The shortcut starts by asking for a number input (e.g., 122, 44). This input is stored in a variable (Provided Input).
  2. Convert Number to String
    It converts the number to text so that individual digits can be extracted using character indexing (this is key — no math like mod or division is used).
  3. Extract Card Rank

If the input is 3 digits, it grabs the first 2 characters (e.g., 12 from 122) using Match groups. If the input is 2 digits, it grabs only the first character (e.g., 4 from 44). This accounts for whether the input is 2 or 3 digits.

  1. Extract Suit
    It takes the last character (using a negative index or substring from end) to get the suit digit.
  2. Map Rank to Name
    It uses a series of If statements to convert ranks. Else Keep number (e.g., “4”)
  3. Map Suit Digit to Suit Name (CHaSeD)
    Another set of If statements maps to set the suit.
  4. Output the Card Name
    Finally, the shortcut combines the rank name + “of” + suit name into the final string.

Input Card and Position

If you want to enter a card and position, it is easy to change the shortcut.

Shortcuts

Download the Input Card and Position shortcut.

How it works

Instead of checking for 2 or 3 digits, check for 4 or 5. (Position must always be two digits with a leading zero added for 1-9 for this to work.)

Then, the routine picks up one character or two (the card value), followed by a single character (the suit), and a two-character digit (the position 1-52).

Note the calculation action towards the end. This removes the leading zero from the position, if there is one.

That's it for now. In the next email, for paid subscribers only, we'll walk through speedily entering further items.