> For the complete documentation index, see [llms.txt](https://docs.iceteagroup.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iceteagroup.com/general/framework/features/salcompileandevaluate.md).

# SalCompileAndEvaluate

*SalCompileAndEvaluate* uses the interpreter built in the PPJ Framework. Which is the same one used to evaluate bind/into variables in embedded SQL statements.

The preferred parser (default) supports C# syntax. However, it is possible to plug in a custom parser and support any syntax, including SAL.

See [Custom Parsers](/general/framework/extensions/custom-parsers.md) for more information on how to plug in your own parser.

## Syntax

By default, the PPJ Framework supports the C# language. If the expressions being evaluated by *SalCompileAndEvaluate*() are simple function calls or variables access, the execution of the expression shouldn't impose any problem.

However, if the expression being evaluated contains operators that are incompatible with C# you will get a syntax error. See the following table to see the most common operators that need to be replaced.

| Operator             | SAL  | C#   |
| -------------------- | ---- | ---- |
| String Concatenation | \|\| | +    |
| Logical And          | AND  | &&   |
| Logical Or           | OR   | \|\| |
| Equality Comparison  | =    | ==   |

**There is an important difference** when using *SalCompileAndEvaluate:* by default inline assignments are disabled to avoid assigning values to a variable when the intention of the expression was to compare the value for equality.

For example, in Team Developer the expression "If nValue = 10" means that the value of nValue should be compared to 10 and the result of the comparison is the result of the expression. However, in C# the single "=" operator is an assignment operator, so the expression above means that 10 should be assigned to nValue and then returned as the result of the expression.

For this reason, when executing expression with the "=" operator but not preceded by a Set keyword, SalCompileAndEvaluate() returns an error for the illegal assignment. The expression should be changed to "If nValue == 10" using the "==" equality operator.

{% hint style="info" %}
You can enable inline assignments by setting a static property on the *ScriptEngine* type:

`PPJ.Runtime.Script.ScriptEngine.AllowInlineAssignments = true;`
{% endhint %}

### Full Script

In Team Developer it was possible to only execute one statement at a time. Using the script engine in the PPJ Framework you can now execute entire scripts using the full C# language.

To run a script you need to enclose the script in a block, as shown in the example below:

```csharp
Sal.CompileAndEvaluate(@"
{
  for (int i = 0; i < 10; i++)
  {
    Sal.MessageBox(i.ToString(), sTitle, 0);
  }
}", ...);
```

### Scope

*SalCompileAndEvaluate*() uses the same scope resolution rules used by the *Sql* module in the PPJ Framework. Basically, local variables are never accessible. All globals, instance and static members are always visible. Local variables can be used in scripts only if they have been extracted into the SqlLocals inner class.


---

# 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://docs.iceteagroup.com/general/framework/features/salcompileandevaluate.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.
