---
title: "strMid"
canonical: "https://help.vicon.com/space/ShogunPost121/1253737094/strMid"
format: markdown
---
# Description

Extracts a sub-string of `count` characters from the middle of another string (`string`), starting at position `firstIndex`. If count is -1, the remainder of string is extracted.

## Functional area

String

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `strMid "string" firstIndex count` |

### Arguments

> Macro (scroll-tablelayout)

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `string` | string | yes | String to extract sub-string from. |
| `firstIndex` | integer | yes | The zero-based index of the first character in string that is to be extracted as a sub-string. |
| `count` | integer | yes | The number of characters to extract from string, counting from `firstIndex`. |

### Flags

None

## Return value

string

Returns the sub-string from a string. 

> Macro (scroll-pagebreak)

## Examples

```plaintext
// Demonstrate usage of strMid
string $str = "This is some text";
string $subStr;
 
// Get 5 characters starting at index 3
$subStr = `strMid $str 3 5`;
print $subStr; 
// Should be "s is "
 
// Get rest of string from index 8
$subStr = `strMid $str 8 -1`;
print $subStr; 
// Should be "some text"
```

# Additional information

## Related commands

- [strCompare](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736489)
- [strFind](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737935)
- [strLeft](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737036)
- [strLength](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253738093)
- [strReplace](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736842)
- [strReverseFind](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737016)
- [strRight](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736764)
- [strTok](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253739563)
- [strTokArray](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253739862)