String Variables in Mini Mouse Macro

Table of Contents
  1. Introduction
  2. Defining String Variables
    1. Basic assignment
    2. Plain values act as SET
  3. String Operations
    1. Supported operations
    2. Examples
    3. Where these operations are used
  4. Parsing Rules
    1. SET consumes text until the next recognized operation
    2. Operation-only expressions work against the current value
    3. Missing required arguments fail
  5. Variables Inside String Operations
    1. Example
    2. Repeated expressions
  6. Numeric Arguments and Padding
  7. String Comparisons in IF Statements
    1. Supported comparison operators
    2. Examples
  8. String Output
    1. Examples
  9. Best Practices
  10. Related Docs

Introduction

String variables store text that can be reused throughout a macro. They are useful for filenames, messages, labels, OCR text, generated commands, and any other value that needs to be treated as text instead of math.

You can use built-in names such as %STRING% and %STRING1%, or define custom names such as %FileName%, %Greeting%, or %ErrorMessage%.


Defining String Variables

Use RUN ACTION | DEFINE STRING VARIABLE to assign or update a string value.

Basic assignment

1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::StartMacro1
2 | RUN ACTION | DEFINE STRING VARIABLE | %Name%::Sam
3 | RUN ACTION | DEFINE STRING VARIABLE | %City%::Sydney

Each example stores the text to the right of :: in the named variable.

Plain values act as SET

If you provide plain text first, Mini Mouse Macro treats it as a SET operation:

1 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::hello
2 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::hello::APPEND:: world

Line 2 is interpreted as:

  1. SET hello
  2. APPEND world

String Operations

RUN ACTION | DEFINE STRING VARIABLE supports stacked string operations. This lets you build or modify a string in several steps within one action.

Supported operations

  • SET::<value>
  • APPEND::<value>
  • PREPEND::<value>
  • CLEAR
  • REPLACE::<old>::<new>
  • INSERT::<index>::<value>
  • REMOVE::<start>
  • REMOVE::<start>::<count>
  • SUBSTRING::<start>
  • SUBSTRING::<start>::<count>
  • TRIM
  • TRIMSTART
  • TRIMEND
  • UPPER
  • LOWER
  • PADLEFT::<width>
  • PADLEFT::<width>::<char>
  • PADRIGHT::<width>
  • PADRIGHT::<width>::<char>

Examples

1 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::hello::APPEND:: world
2 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::APPEND::!
3 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::PREPEND::Say: 
4 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::REPLACE::world::MMM
5 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::TRIM::UPPER
6 | RUN ACTION | DEFINE STRING VARIABLE | %Label%::SET::  abc  ::TRIM::INSERT::1::-::SUBSTRING::0::4::PADRIGHT::6::.

These examples demonstrate that you can:

  • build a value in multiple steps
  • apply operations to the current value without resetting it first
  • chain several operations in one action

The last example produces a-bc...

Where these operations are used

The operations in this section apply when you use:

  • RUN ACTION | DEFINE STRING VARIABLE

Other string features in Mini Mouse Macro use their own formats. For example:

  • IF | STRING VARIABLE | ...
  • non-action variable assignment paths
  • read-side helper expressions such as %VAR%.tolower

Parsing Rules

SET consumes text until the next recognized operation

1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%::SET::hello::world

This stores the literal text hello::world.

Operation-only expressions work against the current value

1 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::hello
2 | RUN ACTION | DEFINE STRING VARIABLE | %Greeting%::APPEND:: world

After line 2, %Greeting% contains hello world.

Missing required arguments fail

Operations such as REPLACE, INSERT, REMOVE, SUBSTRING, PADLEFT, and PADRIGHT require the expected number of arguments. If part of the command is missing, Mini Mouse Macro does not guess what you meant.


Variables Inside String Operations

When you use variables inside a string operation, Mini Mouse Macro resolves their values when the action runs. This lets the same action produce different results as your variables change.

Example

1 | RUN ACTION | DEFINE STRING VARIABLE | %Summary%::%A%::APPEND:: ::APPEND::%B%::LOWER

If %A% resolves to Hello and %B% resolves to World, the final value becomes hello world.

Repeated expressions

If the same string-building action runs repeatedly, such as inside a loop, it uses the current values of your variables each time it runs.


Numeric Arguments and Padding

Some string operations expect numeric values:

  • INSERT
  • REMOVE
  • SUBSTRING
  • PADLEFT
  • PADRIGHT

Additional padding rules:

  • PADLEFT and PADRIGHT default to a space when no pad character is supplied.
  • If the pad-character value resolves to more than one character, only the first character is used.

String Comparisons in IF Statements

String variables are also used in conditions.

Supported comparison operators

  • IS
  • IS NOT
  • CONTAINS

Examples

1 | IF | STRING VARIABLE | %Mode% | IS | StartMacro1 | RUN ACTION | DEFINE STRING VARIABLE | %Mode%::Macro1Process
2 | IF NOT | STRING VARIABLE | %Response% | IS | Yes | RUN ACTION | MESSAGE PROMPT | Please answer Yes::Error
3 | IF | STRING VARIABLE | %FileName% | CONTAINS | Report | RUN ACTION | DEFINE STRING VARIABLE | %FilePath%::D:\Reports\%FileName%

These comparisons use their own condition format.


String Output

String variables can be inserted into prompts, typed output, filenames, and other action parameters.

Examples

1 | RUN ACTION | DEFINE STRING VARIABLE | %FileName%::Report_%RANDOM_1-999%
2 | RUN ACTION | MESSAGE PROMPT | Current file: %FileName%::Info
3 | 2409 | 790 | 200 | Keypress My string variable is equal to %FileName%

Best Practices

  • Use descriptive names for strings with a clear business purpose.
  • Use stacked operations when one action needs to build or normalize text in several steps.
  • Prefer explicit SET when you want the operation sequence to be obvious to a reader.
  • Use the formats on this page with RUN ACTION | DEFINE STRING VARIABLE.

Back to Top