User Tools

Site Tools


action:Switch_or_Case

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
action:Switch_or_Case [2021/10/15 01:20]
peternlewis
action:Switch_or_Case [2022/09/17 22:49]
peternlewis [Switch/Case Action]
Line 4: Line 4:
  
 The _Switch_ Action is a good alternative to using multiple, nested, [[action:​If_Then_Else|If/​Then]] Actions. The _Switch_ Action is a good alternative to using multiple, nested, [[action:​If_Then_Else|If/​Then]] Actions.
 +
 +The actions in the first section that matches will be executed. If no section matches, then no actions will be executed and the execution will continue after the Switch/Case action. Under no circumstances will actions from more than one section be executed - that is, execution does not “fall through” to following sections as happens in some languages.
  
 ===== Parameters ===== ===== Parameters =====
Line 10: Line 12:
   * [[:​Clipboards|System Clipboard]]   * [[:​Clipboards|System Clipboard]]
   * [[:​Clipboards#​Named_Clipboards|Named Clipboard]]   * [[:​Clipboards#​Named_Clipboards|Named Clipboard]]
 +  * [[token:​TriggerClipboard|Trigger Clipboard]]
   * [[manual:​Variables|Keyboard Maestro Variable]]   * [[manual:​Variables|Keyboard Maestro Variable]]
   * Text (which can use [[:​Tokens|Tokens]])   * Text (which can use [[:​Tokens|Tokens]])
 +  * [[manual:​Calculations|Calculation]]
 +  * File
  
 ===== Default Configuration ===== ===== Default Configuration =====
Line 17: Line 22:
 When you insert the _Switch_ Action, it is configured to switch based on the _System Clipboard_, but can be easily changed to other parameters. ​ It initially looks like this: When you insert the _Switch_ Action, it is configured to switch based on the _System Clipboard_, but can be easily changed to other parameters. ​ It initially looks like this:
  
-{{:action:km-7.3-switch.png?​nolink|}}+{{:action:switch-case.png?​nolink|}}
  
 For each _Condition_ that you add, you can enter zero or more _Actions_ that will be executed when that _Condition_ is met.  After those _Action(s)_ are executed, or if no _Conditions_ are met, the _Switch_ Action is exited. For each _Condition_ that you add, you can enter zero or more _Actions_ that will be executed when that _Condition_ is met.  After those _Action(s)_ are executed, or if no _Conditions_ are met, the _Switch_ Action is exited.
Line 23: Line 28:
 ===== Conditions ===== ===== Conditions =====
  
-The _Conditions_ available depend on the _Parameter_ that is chosen+The _Conditions_ available depend on the _Parameter_ that is chosen ​(for example, you cannot use *has an image* with a calculation).
-{{:​action:​km-7.3-switch-conditions.png?​nolink|}}+
  
 The _Conditions_ are defined as follows: The _Conditions_ are defined as follows:
  
 ^Condition^Definition^ ^Condition^Definition^
 +|is empty|The text is contains no characters.|
 +|is not empty|The text is contains some characters.|
 |has text |Clipboard has at least one item containing text of some sort.| |has text |Clipboard has at least one item containing text of some sort.|
 |does not have text |Clipboard does not have any text items.| |does not have text |Clipboard does not have any text items.|
Line 35: Line 41:
 |is |is exactly (case insensitive) the specified string.| |is |is exactly (case insensitive) the specified string.|
 |is not |is not exactly (case insensitive) the specified string.| |is not |is not exactly (case insensitive) the specified string.|
-|is before |is alphabetically before the specified string. (v7.2+)| 
-|is after |is alphabetically after the specified string. (v7.2+)| 
 |contains |contains (case insensitive) the specified string.| |contains |contains (case insensitive) the specified string.|
 |does not contain |does not contain (case insensitive) the specified string.| |does not contain |does not contain (case insensitive) the specified string.|
 +|starts with |starts with the specified string.|
 +|ends with |ends with the specified string.|
 +|is before |is alphabetically before the specified string. (v7.2+)|
 +|is after |is alphabetically after the specified string. (v7.2+)|
 |matches |matches the specified regular expression.| |matches |matches the specified regular expression.|
 |does not match |does not match the specified regular expression.| |does not match |does not match the specified regular expression.|
 +|is <|is numerically less than.|
 +|is <=|is numerically less than or equal.|
 +|is =|is numerically equal.|
 +|is >=|is numerically greater than or equal.|
 +|is >|is numerically greater than.|
 +|is !=|is numerically not equal.|
 |conforms to |Clipboard has an item with the UTI class that conforms to the specified [Uniform Type Identifier](https://​en.wikipedia.org/​wiki/​Uniform_Type_Identifier).| |conforms to |Clipboard has an item with the UTI class that conforms to the specified [Uniform Type Identifier](https://​en.wikipedia.org/​wiki/​Uniform_Type_Identifier).|
 |does not conform to |Clipboard does not have an item with the UTI class that conforms to the specified Uniform Type Identifier.| |does not conform to |Clipboard does not have an item with the UTI class that conforms to the specified Uniform Type Identifier.|
Line 46: Line 60:
  
  
-The _Otherwise_ _Condition_ will execute if none of the above _Conditions_ are met.  The _Switch_ Action will then exit.  So, the _Otherwise_ _Condition_ should always be placed as the last _Condition_ in the _Switch_ Action. +The _Otherwise_ _Condition_ will execute if none of the previous ​_Conditions_ are met.  The _Switch_ Action will then exit.  So, the _Otherwise_ _Condition_ should always be placed as the last _Condition_ in the _Switch_ Action.
- +
----- +
  
 ===== See Also ===== ===== See Also =====
action/Switch_or_Case.txt · Last modified: 2022/09/17 22:49 by peternlewis