---
url: >-
  /statelake/scripting-reference/functions-and-procedures/string-functions/midstr.md
---

# MidStr

The **MidStr** function returns a substring of the string given in **Atext**, starting at the specified character **AStart**, for the length of **ACount** characters.

**Declaration**: Function MidStr( const AText : string; const AStart, ACount : Integer) : string;

An example is.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  Str1, Str2 : string;
begin
  Str1 := 'Kathy Reichs is a Forensic Anthropologist to the province of Quebec, Canada.'
  Str2 := MidStr(Str1, 19, 23);
  LogInfo(Str2);               //Result is  'Forensic Anthropologist'
end;
```

Also see the **RightStr** and **LeftStr** functions [RightStr](/statelake/scripting-reference/functions-and-procedures/string-functions/rightstr) and [LeftStr](/statelake/scripting-reference/functions-and-procedures/string-functions/leftstr).
