Mid

This is a pre-built Action located under the @Generic Element. The functionality of this Action in Avo Assure is to extract the middle character from the given input text. The extracted character is then stored in a dynamic variable.

Syntax

Input Value: <string>

Note: If the input string is provided in even number of characters, then it returns the mid+1 [(length/2) + 1] value.

Argument
Description

<string>

(Required)

Provide the string from which the middle character will be extracted.

Output Value: <Dynamic Variable>;<Dynamic Variable>(Optional)

Argument
Description

<Dynamic Variable>

(Required)

This dynamic variable holds the extracted middle character.

<Dynamic Variable>

(Optional)

This dynamic variable stores the status as True or False.

Example 1: Extracting the Middle Characters from a String

In this example, we explain how to extract the middle portion of a string using.

  • Action: Mid

  • Input Value: Michael Brown

    • This specifies the string from which the middle character will be extracted.

  • Output Value: {Mid String}

    • The extracted middle portion of the string (e.g., l) is stored in this {Mid String} dynamic variable for further use.

    • If the second output variable is defined, it stores the action status with the following possible values:

      • True: If the middle character is successfully extracted.

      • False: If the extraction fails due to invalid input or configuration.

  • Logical Explanation: The Mid action fetches the value from the Input Value column (Michael Brown) and extracts the middle character from the string which is (l). The extracted middle portion is stored in the {Mid String} variable.

Example 2: Extracting the Middle Character from an Even-Length String

In this example, we explain how to extract the middle character from an even-length string.

  • Action: Mid

  • Input Value: Emma

    • This specifies the string from which the middle character will be extracted.

  • Output Value: {Mid String}

    • The extracted middle character (e.g., m) is stored in this {Mid String} dynamic variable for further use.

    • If the second output variable is defined, it stores the action status with the following possible values:

      • True: If the middle character is successfully extracted.

      • False: If the extraction fails due to invalid input or configuration.

  • Logical Explanation: The Mid action fetches the string from the Input Value column (Emma) and identifies the middle position. Since the string has an even number of characters (4), the action extracts the character at the mid + 1 position.

Process:

  • String Length = 4

  • Middle (String Length/2) = 4 ÷ 2 = 2

  • mid + 1 = 2 + 1 = 3 → Character at position 3 is “m”

The extracted middle portion (m) is stored in the {Mid String} variable.

Knowledge Bites: Below are some examples of different string scenarios

String
Input Value
Result

Text Strings

Automation

a

Numeric Strings

123456

4

Special Character

a

Alphanumeric strings

ID2025

0

Even-Length String

User

e

Last updated

Was this helpful?