Home > lang > eval 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs tr ar fa id ko ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Search  Administration  
Documentation  
Warning! This page is not translated.  See english version 
Eval
Value = Eval ( Expression AS String [ , Context AS Collection ] ) AS Variant

Evaluates an expression and returns its value. This expression can use almost all operators and subroutines of Gambas.

The optional context is a collection that must contain the value of each undefined symbol of Expression.

Example

DIM Context AS New Collection

Context["X"] = 2
Context["Y"] = "Gambas"

PRINT Eval("X * Len(Y)", Context)

12

Assignments

By starting the expression with the LET keyword, you can evaluate an assignment. In that case, the assigned value is returned.

The assignment expression can use any assignment operators, but cannot use the instructions that return something, like OPEN, NEW...

This assigned expression can use almost all operators and subroutines of Gambas.

Example

Dim Context AS New Collection

Context["X"] = "Liberation Serif"

Print Application.Font.ToString()
Print Eval("Let Application.Font = Font[X]", Context)
Print Application.Font.ToString()

Sans,10
(Font 0x8fae9e8)
Liberation Serif,10

See also

gb.eval