I am trying to get the absolute value of a number (dynamic) and to do that I am using the Calculate Mathematical Expression command, but I can't manage to make it work when using variables in the expression. It does work if I manually insert the values inside the expression, but it's useless that way. Here is what I am trying to do:
defVar --name number --type Numeric
defVar --name outputValue --type Numeric
setVar --name "${number}" --value "1.2"
evaluate --expression "Math.Abs(${number})" outputValue=value
logMessage --message "${outputValue}" --type "Info"
The error I get:
DynamicExpresso.NoApplicableMethodException: No applicable method 'Abs' exists in type 'Math' (at index 5).
at DynamicExpresso.Parsing.Parser.ParseMethodInvocation(Type type, Expression instance, Int32 errorPos, String methodName)
at DynamicExpresso.Parsing.Parser.ParseMemberAccess(Type type, Expression instance)
at DynamicExpresso.Parsing.Parser.ParseIdentifier()
at DynamicExpresso.Parsing.Parser.ParsePrimary()
at DynamicExpresso.Parsing.Parser.ParseUnary()
at DynamicExpresso.Parsing.Parser.ParseMultiplicative()
at DynamicExpresso.Parsing.Parser.ParseAdditive()
at DynamicExpresso.Parsing.Parser.ParseTypeTesting()
at DynamicExpresso.Parsing.Parser.ParseComparison()
at DynamicExpresso.Parsing.Parser.ParseLogicalAnd()
at DynamicExpresso.Parsing.Parser.ParseLogicalOr()
at DynamicExpresso.Parsing.Parser.ParseConditional()
at DynamicExpresso.Parsing.Parser.ParseAssignement()
at DynamicExpresso.Parsing.Parser.ParseExpressionSegment(Type returnType)
at DynamicExpresso.Parsing.Parser.Parse()
at DynamicExpresso.Interpreter.ParseAsLambda(String expressionText, Type expressionType, Parameter[] parameters)
at WDG.Automation.Base.EvaluateCommand.Execute(AutomationContext context)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at WDG.Automation.Language.ErrorHandler.m0nvU46Nja(Exception )
at WDG.Automation.Language.ErrorHandler.HandleExecutionExceptionIfNeeded(Exception exception, IAutomationCommand command)
at WDG.Automation.Language.CommandInterpreter.<Run>d__12.vQ7xHXNECMOJPEvfGI5(Object , Object , Object )
at WDG.Automation.Language.CommandInterpreter.<Run>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at WDG.Automation.Language.ScriptInterpreter.<RunCore>d__17.MoveNext()
Am I doing something wrong or is this a bug?
------------------------------
Vinicius Marques
------------------------------