Table of contents
TOC
Collapse the table of content
Expand the table of content

Expression.Evaluate

Owen Duncan|Last Updated: 10/5/2018
|
1 Contributor

About

Evaluates a Text expression and returns the evaluated value.

Expression.Evaluate(expression as text, optional environment as [...]) as any  

Arguments

ArgumentDescription
expressionThe expression to evaluate.
optional environmentThe expression environment.

Examples

Expression.Evaluate("1 + 1") equals 2

Expression.Evaluate("1 +") equals Error

Expression.Evaluate(

"section Section1; shared X = 1;"

) equals Error, only expressions are supported

Expression.Evaluate(

"Record.Field([A=1], ""A"")"

) equals error. Unknown identifier "Record.Field".

Expression.Evaluate(

"Record.Field([A=1], ""A"")",

[Record.Field = Record.Field]

) equals 1

let

x = 1

in

Expression.Evaluate("x") equals Error. Unknown identifier "x".

let

x = 1

in

Expression.Evaluate(

"x",

#shared

) equals Error. Unknown identifier "x".

let

x = 1

in

Expression.Evaluate("x", [x = x]) equals 1

section;

shared MyText = "ABC";

MyResult = Expression.Evaluate(

"Text.StartsWith(MyText, ""A"")",

#shared

); // true

section;

MyText = "ABC";

MyResult = Expression.Evaluate(

"Text.StartsWith(MyText, ""A"")",

#shared

); equals Error. Unknown identifier "MyText" (since MyText isn't shared).

© 2018 Microsoft