ScriptTap
SetVariable

Command video guide

SetVariable

SetVariable stores a named value so later commands can reuse it. It does not type into an app or display a dialog by itself. This walkthrough covers Single mode and demonstrates a String displayed by a supporting PromptMe command.

Create and name a separate script. Expand Variables, manually drag SetVariable into Live Script, then double-tap the inserted row.

  • Integer: whole numbers. Decimal: fractional numbers. Boolean: True or False. Hex: a color. String: text. Time: a time value.
  • Name: one English letter, optionally followed by an index from 1 to 4096. Names are case-insensitive. Names sharing a letter in the same scope must share a type. This example uses String s1.
  • Use In: This Script Only keeps the value local; Script Thread shares it within the current script thread.
  • Value: enter a literal, or a previously written variable of the same type. Define a source variable before using it. The demonstration uses literal text Hello ScriptTap.
  • Set from clipboard: a Single String can read the device clipboard when the command runs. Enabling this option requires consent. This example declines and keeps the typed value.

Save with OK; reopen the command to confirm its settings. Manually drag PromptMe after SetVariable. Keep Standard mode, set Header to s1, add a Done button, and use Boolean b1 for that button's output. Leave Use Toggles & Text off. The header resolves the defined String's value; the button flag does not modify it.

Close the editor and use Play. SetVariable assigns the text before PromptMe reads it, so the header displays Hello ScriptTap. Press Done to finish automatically. The same stored value can be reused by later messages, text typing and transformations.

Single Variables

Step-by-step guide

  1. Step 01

    Set Variable gives a value a name so later commands can use it. Use it to prepare text, numbers, colors, or flags for a script. Here, we will store some text and display its value with PromptMe.

    SetVariable step 1: Set Variable gives a value a name so later commands can use it. Use it to prepare text, numbers, colors, or flags for a script. Here, we will store some text and display its value with PromptMe.
  2. Step 02

    Open the main overlay menu, then choose Scripts to open the Script Library.

    SetVariable step 2: Open the main overlay menu, then choose Scripts to open the Script Library.
  3. Step 03

    Tap New Script and choose Blank Script.

    SetVariable step 3: Tap New Script and choose Blank Script.
  4. Step 04

    Scroll to the new row if it is outside the visible list. This will be a separate example; existing scripts remain unchanged.

    SetVariable step 4: Scroll to the new row if it is outside the visible list. This will be a separate example; existing scripts remain unchanged.
  5. Step 05

    Open the new script's three-dot menu and choose Rename. Give it a descriptive name so it is easy to find again, then tap OK.

    SetVariable step 5: Open the new script's three-dot menu and choose Rename. Give it a descriptive name so it is easy to find again, then tap OK.
  6. Step 06

    Select the new script, open the Script Editor, and collapse the extra overlay controls.

    SetVariable step 6: Select the new script, open the Script Editor, and collapse the extra overlay controls.
  7. Step 07

    Collapse Recent if needed. Expand Variables, then drag Set Variable from the palette into the Live Script column. Release at the insertion line. Double-tap the new frame to open its settings.

    SetVariable step 7: Collapse Recent if needed. Expand Variables, then drag Set Variable from the palette into the Live Script column. Release at the insertion line. Double-tap the new frame to open its settings.
  8. Step 08

    Integer is for whole numbers; Decimal allows fractions; Boolean stores True or False; Hex stores a color; String stores text; and Time stores a time. We will use String in this example. This walkthrough covers Single mode.

    SetVariable step 8: Integer is for whole numbers; Decimal allows fractions; Boolean stores True or False; Hex stores a color; String stores text; and Time stores a time. We will use String in this example. This walkthrough covers Single mode.
  9. Step 09

    A variable name uses one English letter, optionally followed by an index from one to four thousand ninety-six. Names ignore letter case. Keep the same type for names that share a letter in the same scope. We will name this String s1.

    SetVariable step 9: A variable name uses one English letter, optionally followed by an index from one to four thousand ninety-six. Names ignore letter case. Keep the same type for names that share a letter in the same scope. We will name this String s1.
  10. Step 10

    Use In controls the variable's scope. This Script Only keeps it local. Script Thread shares it within the current script thread. We will keep This Script Only.

    SetVariable step 10: Use In controls the variable's scope. This Script Only keeps it local. Script Thread shares it within the current script thread. We will keep This Script Only.
  11. Step 11

    Enter Hello ScriptTap as the value. Set Variable stores this text when the script reaches the command. It does not type into an app or show a dialog by itself.

    SetVariable step 11: Enter Hello ScriptTap as the value. Set Variable stores this text when the script reaches the command. It does not type into an app or show a dialog by itself.
  12. Step 12

    The value can also come from an earlier variable of the same type. Define that source first. Here, we are using literal text.

    SetVariable step 12: The value can also come from an earlier variable of the same type. Define that source first. Here, we are using literal text.
  13. Step 13

    A Single String can also read the current device clipboard when the command runs. That option asks for consent. We will decline and keep our typed value.

    SetVariable step 13: A Single String can also read the current device clipboard when the command runs. That option asks for consent. We will decline and keep our typed value.
  14. Step 14

    Tap OK. The script row shows the variable's name, type, and value.

    SetVariable step 14: Tap OK. The script row shows the variable's name, type, and value.
  15. Step 15

    Reopen the command to confirm the settings are saved, then close it with the X.

    SetVariable step 15: Reopen the command to confirm the settings are saved, then close it with the X.
  16. Step 16

    To make the result visible, collapse Variables, expand Advanced, and scroll to PromptMe. Drag it after Set Variable. This supporting command displays the stored text; it does not create our String variable.

    SetVariable step 16: To make the result visible, collapse Variables, expand Advanced, and scroll to PromptMe. Drag it after Set Variable. This supporting command displays the stored text; it does not create our String variable.
  17. Step 17

    Open PromptMe. Keep Standard mode and enter s1 in Header. PromptMe recognizes this defined String name and displays its current value, rather than the name itself.

    SetVariable step 17: Open PromptMe. Keep Standard mode and enter s1 in Header. PromptMe recognizes this defined String name and displays its current value, rather than the name itself.
  18. Step 18

    Click the plus to add a button. Set its caption to Done. Enter b1 for its Boolean output. That flag records which button was pressed; it does not change s1. Now tap OK.

    SetVariable step 18: Click the plus to add a button. Set its caption to Done. Enter b1 for its Boolean output. That flag records which button was pressed; it does not change s1. Now tap OK.
  19. Step 19

    Our script sets s1 to Hello ScriptTap, then reads s1 for the prompt header. The second command makes the stored value visible.

    SetVariable step 19: Our script sets s1 to Hello ScriptTap, then reads s1 for the prompt header. The second command makes the stored value visible.
  20. Step 20

    Close the editor to return to the home screen.

    SetVariable step 20: Close the editor to return to the home screen.
  21. Step 21

    When the script is complete, simply use the Play button in the main overlay.

    SetVariable step 21: When the script is complete, simply use the Play button in the main overlay.
  22. Step 22

    The header now says Hello ScriptTap, the value assigned by our script. Later commands can use the same String for messages, text typing, or transformations.

    SetVariable step 22: The header now says Hello ScriptTap, the value assigned by our script. Later commands can use the same String for messages, text typing, or transformations.
  23. Step 23

    Press Done. The script finishes automatically. Use the stored value in later commands whenever your script needs to reuse information.

    SetVariable step 23: Press Done. The script finishes automatically. Use the stored value in later commands whenever your script needs to reuse information.