Eval -- evaluate string expression (V5.0)
val = Eval(expr$[, table])
Eval() evaluates the numeric expression passed to it in expr$ and returns its result as a number. The string passed in expr$ can use all operators that are recognized by Hollywood except the string concatenation operator because this operator requires a string while the Eval() function only works with numbers. You can also prioritize certain subexpressions by using parentheses. The operators defined by Eval() use the same priorities as in Hollywood itself. See Operator priorities for a list of all Hollywood operators and their priorities.

Numbers inside expr$ can be specified in decimal or hexadecimal format. If you use hexadecimal format, you have to prefix the number using the $ dollar sign.

It is also possible to use variables in the expression. Your script variables, however, are not automatically available to Eval(). You need to pass the value of every variable that should be visible to Eval() inside a table in the optional table argument. Here is a list of all tags currently supported by the optional table argument:

This tag can be used to pass an array of variables that you want your expression to be able to access to Eval(). You have to pass an array here that consists of a number of Name and Value pairs. Name must contain the desired name for the variable and Value must contain the value the variable should be initialized to. The semantics of the variable name are the same as in Hollywood, i.e. it is only allowed to use alphanumerical characters plus the special characters "$", "!", and "_". The first character must not be a number. See below for an example.

numeric expression to evaluate
optional: table containing further arguments
evaluation result
v = Eval("5*(6+1)")
The call above returns 35.

v = Eval("var1*(var2+1)", {Variables = {{Name = "var1", Value = 5},
         {Name = "var2", Value = 6}}})
The code above does the same as the first example but uses variables instead of direct numbers.

Show TOC