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

# AddQuotes

The **AddQuotes** function encapsulates the parameter value **aValue** in quote marks (enquoting), comprised of the character specified by **aChar**.

If **aValue** is already enquoted, then nothing happens and **aValue** is returned without change.

If the **aValue** string already contains the **aChar** character, then the character as it appears within the string will need to be pre-fixed with an escape character so that it is treated as a data character, and not an end-of-the-string character. So this in-string data character will need to be **escaped**.

::: info
**Escaping** simply means that a text character within a string is preceded by another symbol that indicates that the character following the escape symbol should interpreted literally and should be treated as text only, and is not a control character.
:::

::: warning
This function does not handle the presence of any double-quote marks (“) within the string being enquoted. Even when using **escaping**.
:::

**Declaration**: Function AddQuotes( const aValue : string; aChar : Char) : string

Examples which include showing a single-quote being escaped.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  Str1, Str2, Str3 : string;
begin
 //Returns "Pirates"
  Str1 := AddQuotes('Pirates','"');

 //Returns "O'Sullivan"
  Str2 := AddQuotes('O''Sullivan','"');

 //The following text includes double-quotes.
 //Returns       Churchill said "If you're going through hell, keep going."
  LogInfo('Churchill said "If you''re going through hell, keep going."');

 {But the AddQuote function requires these to be replaced by double single-quotes.
  It does not handle double-quotes.}
 //Returns "Churchill said 'If you're going through hell, keep going.'"
  Str3 := AddQuotes('Churchill said ''If you''re going through hell, keep going.''', '"');

  LogInfo(Str1);
  LogInfo(Str2);
  LogInfo(Str3);

end;
```
