This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
action:Set_Variable_to_Text [2017/07/14 19:11] JMichaelTX Add example for combining text and variables/tokens |
action:Set_Variable_to_Text [2023/09/15 05:44] (current) peternlewis |
||
---|---|---|---|
Line 2: | Line 2: | ||
The Set Variable to Text action allows you to set a selected variable to plain text, by either typing in the text box, or selecting a [[:Tokens|Token]]. | The Set Variable to Text action allows you to set a selected variable to plain text, by either typing in the text box, or selecting a [[:Tokens|Token]]. | ||
+ | |||
+ | Alternatively (v9.0+), you can Prepend the text to the variable, or Append the text to the variable by selecting from the action (gear) ⚙ menu. | ||
{{:action:set-variable-text-token-popup.png?nolink|}} | {{:action:set-variable-text-token-popup.png?nolink|}} | ||
- | --- | + | You can (v11.0+) set a specific array entry within the action. You can delete the entry by setting it to `%Delete%`. |
===== Examples ===== | ===== Examples ===== | ||
+ | |||
==== Set To Text You Type ==== | ==== Set To Text You Type ==== | ||
Line 19: | Line 22: | ||
{{:action:set-variable-text-to-variable.png?nolink|}} | {{:action:set-variable-text-to-variable.png?nolink|}} | ||
+ | |||
+ | See below for how to use dynamic variable names. | ||
==== Combine Multiple Variables and Text ==== | ==== Combine Multiple Variables and Text ==== | ||
+ | |||
There is no need to use any operators when combining text with multiple variables or other tokens. Just enter the text and variables/tokens as you would like them to appear in the Variable being set by this Action. | There is no need to use any operators when combining text with multiple variables or other tokens. Just enter the text and variables/tokens as you would like them to appear in the Variable being set by this Action. | ||
{{:action:set-variable-text-combine-var.png?nolink|}} | {{:action:set-variable-text-combine-var.png?nolink|}} | ||
- | --- | + | ==== Append to Variable ==== |
- | ===== Setup ===== | + | You can append directly to a variable with the //Append// variant of the action: |
- | Select the variable to set from the //Set variable// pop-up or enter a variable name. | + | {{append-variable-with-text.png?nolink&512x157| Append to Variable }} |
- | Enter the text to use in the text area. | + | or equivalently using text tokens to expand the variable: |
- | Use the arrow at the right of the text area to select variables, calculations, clipboards and other tokens to enter in the text area. | + | {{set-append-variable-with-text.png?nolink&512x157| Set Append to Variable }} |
+ | |||
+ | ==== Set Second Line of Variable ==== | ||
+ | |||
+ | You can specify an array entry of the variable to set. By default, entries are comma separated, but you can specify an specific separator after the closing square bracket (`]`), | ||
+ | |||
+ | {{ set-second-line-of-variable-example.png?nolink&512x310 | Set Second Line of Variable Example }} | ||
+ | |||
+ | ===== Setup ===== | ||
+ | |||
+ | Configure the Action as Needed | ||
+ | |||
+ | - Select the variable to set from the //Set variable// pop-up or enter a variable name. | ||
+ | - In the text area, Enter the text and/or [[:Tokens|Tokens]] (which include Variables). | ||
+ | - You may intermix text and tokens as much as you like | ||
+ | - You can type the Token, in the format of `%TokenName%`, or select it from the popup list under //Insert Token//. | ||
+ | - [[:Tokens|Tokens]] include variables, calculations, clipboards and more. | ||
+ | - You can create a dynamic variable name using this format: `%Variable%%%Variable%myVar%%%` | ||
Unlike most places you specify a variable, the variable name itself is a text token field, so you can set a variable whose name changes. | Unlike most places you specify a variable, the variable name itself is a text token field, so you can set a variable whose name changes. | ||
Line 47: | Line 70: | ||
Tip: leave notes for yourself about what you're doing. Click on the gear icon at top right of the action to select //Set Note…//. A window appears where you can enter text. Click the OK button to save the text of the note for future reference. | Tip: leave notes for yourself about what you're doing. Click on the gear icon at top right of the action to select //Set Note…//. A window appears where you can enter text. Click the OK button to save the text of the note for future reference. | ||
- | ===== See Also ===== | + | ===== How To Use Dynamic Variable Names ===== |
- | ---- | + | In some languages, this is known as //indirection//, where one variable is really referring to another variable. This is a bit complicated, and you may not often need it, but it is very useful when you do need it. |
+ | |||
+ | ==== Dynamic Determination of Variable Name in Text Area Block ==== | ||
+ | |||
+ | **This requires two steps (two Actions):** | ||
+ | |||
+ | {{:action:set-variable-text-dynamic-var.png?nolink|}} | ||
+ | |||
+ | **The Steps Are** | ||
+ | * **STEP 1.**\\ //Set Variable to Text Action// (this action) to dynamically determine a standard variable token based on one or more variables, which optional text. | ||
+ | * In the text area of the Action, enter a special form of the Token entity, where you will embed another Variable token, and optionally text. | ||
+ | * For example: `%%Variable%%myVar%Variable%myVarNum%%%` | ||
+ | * Note the use of two percent symbols (`%%`) in places where you want the result to be one `%`. | ||
+ | * Here is how this text will be processed when the Action executes:\\ .<code> | ||
+ | %%Variable%%myVar%Variable%myVarNum%%% | ||
+ | |||
+ | TEXT BECOMES | ||
+ | %% % | ||
+ | Variable Variable | ||
+ | %% % | ||
+ | myVar myVar | ||
+ | %Variable%myVarNum% 2 | ||
+ | %% % | ||
+ | |||
+ | RESULT WHEN EXECUTED | ||
+ | %Variable%myVar2% | ||
+ | </code> | ||
+ | * This is the variable we want to get the results of, so we will need another Action to get it.\\ | ||
+ | * **STEP 2.**\\ [[action:Filter|Filter Action]] using the //Process Tokens// option. | ||
+ | |||
+ | ==== Dynamic Determination in Variable Name Block ==== | ||
+ | |||
+ | Since the Variable Name block of the //Set Variable to Text// Action accepts tokens, we can just use it directly if we just need to concatenate two more more Variables, with optional text. | ||
+ | * For example: `%Variable%myPrefix%%Variable%myFieldName%` | ||
+ | * When this action executes, it will first evaluate these tokens to produce something like: `myAddress`, and then set that Variable to the results in the Text Area block. | ||
+ | |||
+ | |||
+ | {{:action:set-variable-text-dynamic-var-name.png?nolink|}} | ||
+ | |||
+ | ===== See Also ===== | ||
- | === Actions === | + | ==== Actions ==== |
+ | * Prepend Text to Variable | ||
+ | * Set Variable to Text | ||
+ | * Append Variable with Text | ||
* [[action:Set Variable to Calculation|Set Variable to Calculation]] | * [[action:Set Variable to Calculation|Set Variable to Calculation]] | ||
* [[action:Set Variable to Keychain Password|Set Variable to Keychain Password]] | * [[action:Set Variable to Keychain Password|Set Variable to Keychain Password]] | ||
Line 58: | Line 123: | ||
* [[:Actions|See all Actions]] | * [[:Actions|See all Actions]] | ||
- | ---- | ||
==== Forum ==== | ==== Forum ==== | ||