> For the complete documentation index, see [llms.txt](https://mind-expression-docs.gitbook.io/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mind-expression-docs.gitbook.io/home/how-to-guides/intelligent-process/smalltalk-with-mind-expression.md).

# Mindscript with Mind Expression

## MindScript Container

We provide support for rendering code within a container environment.

To indicate code to be rendered, it should be enclosed within `{{$` and `}}`. For instance, if the `response-template` field in a subject definition contains the following content:

```
A new format of it is {{$ sel dateFormat: 'MM/DD/YYYY'}}
```

If the `sel` is applied to the most recent input from the user, which is the query '2022-09-09', it would result in the displayed text.

```
A new format of it is 09/09/2022
```

That means, we interpret `sel dateFormat: 'MM/DD/YYYY'` as a MindScript code.

You can find the available MindScript classes and methods documentation for a container through the engine API at /public/v1/talk/documentation.

In addition to the engine API, this handbook provides documentation for all MindScript classes and methods.

## Cheat sheet reference for SQL functions

| SQL Function | MindScript method       | Description                                                   | Example                                                                              |
| ------------ | ----------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| ABS          | abs                     | returns the absolute value of a number                        | ab := -243.2 abs.                                                                    |
| CAST         | asInteger               | to change the data type of a value into the other type.       | '123' asIntger.                                                                      |
|              | asNumber                |                                                               | '12.2' asNumber.                                                                     |
|              | asString                |                                                               | 12 asString.                                                                         |
| REPLACE      | replaceAll: with:       | replace all occurrences of a string                           | ch := 'This is a string' replaceAll: 'is' with: 'was'. "ch = Thwas was a string"     |
| CHARINDEX    | findString:             | locate the beginning position of a substring in a string      | position := 'This is a string' findString: 'is'                                      |
|              | findString: startingAt: |                                                               | position := 'This is a string' findString: 'is' startingAt: 2.                       |
| FORMAT       | asCustomNumber:         | formats a value with the specified format                     | 123456789 asCustomNumber: '##-##-#####'. "12-34-56789"                               |
| LEFT         | left:                   | extracts a number of characters from a string (from left)     | str := 'abcdefg' left: 5. "str = abcde"                                              |
| RIGHT        | right:                  | extracts a number of characters from a string (from right)    | ri := 'abcdefg' right: 5. "ri = cdefg"                                               |
| LEN          | size                    | returns the length of a string                                | length := 'W3Schools.com' size. "length = 13"                                        |
| LOWER        | asLowercase             | Convert the text to lower-case                                | lw := 'A string' asLowercase. "lw = a string"                                        |
| UPPER        | asUppercase             | Convert the text to upper-case                                | up := 'A string' asUppercase. "up = A STRING"                                        |
| LTRIM        | trimLeft                | Remove leading spaces from a string                           | tl := ' A string' trimLeft. "tl = A string"                                          |
| RTRIM        | trimRight               | Remove trailing spaces from a string                          | tr := 'A string' trimRight. "tr = A string"                                          |
| SUBSTRING    | copyFrom: to:           | extracts some characters from a string                        | substr := 'abcdefg' copyFrom: 1 to 5. "substr = abcde"                               |
| FLOOR        | floor                   | the largest integer value of a number                         | fl := 25.75 floor. "fl = 25"                                                         |
| RAND         | Random                  | a random number between 0 (inclusive) and 1 (exclusive)       | ran := Random between: 0 and: 6. "ran >= 0 and: rand < 6"                            |
| ROUND        | asCustomNumber:         | rounds a number to a specified number of decimal places       | (234.414 asCustomNumber: '0.00') asNumber. "234.41"                                  |
| DATEDIFF     | dateDiff: as:           | find the difference between two dates                         | dy := '2017/08/25' dateDiff: '2019/08/25' as: #year. "dy = 2"                        |
| DATEADD      | dateAdd: as: format:    | adds a time/date interval to a date and then returns the date | date := '2017/08/25' dateAdd: 2 as: #month format: 'YYYY/MM/DD'. "date = 2017/10/25" |
| DATEPART     | dateFormat:             | a specified part of a date                                    | yyyy := ('2017/08/25' dateFormat: 'YYYY') asInteger. "yyyy = 2017"                   |
| DAY          | dateFormat:             | the day of the month (from 1 to 31) for a specified date      | dd := ('2017/08/25' dateFormat: 'DD') asInteger. "dd = 25"                           |
| MONTH        | dateFormat:             | the month part for a specified date (a number from 1 to 12)   | mm := ('2017/08/25' dateFormat: 'MM') asInteger. "mm = 8"                            |
| YEAR         | dateFormat:             | the year part for a specified date                            | yyyy := ('2017/08/25' dateFormat: 'YYYY') asInteger. "yyyy = 2017"                   |
| GETDATE      | dateFormat:             | the current database system date and time                     | now := 'now' dateFormat: 'YYYY-MM-DD'. "now is a date string of now"                 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mind-expression-docs.gitbook.io/home/how-to-guides/intelligent-process/smalltalk-with-mind-expression.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
