cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluate an expression in a rule?

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer

Does anyone have, or know of, a way to take a rule which holds a valid RS expression inside it's string value and evaluate that expression?

 

A VB function or SQL Stored procudure, perhaps?

Background:

I want my application users to have the option of typing an expression into a text box in the app's UI, and have a way for my rules to evaluate that expression to get a string or number back.

 

Any other ideas on how one might do that?

 

Thanks,

Gene

Gene Libardi
Principal Solutions Architect
Engineering Intent Corporation
www.EngineeringIntent.com


2 REPLIES

Re: Evaluate an expression in a rule?

Experimenter
Experimenter

One possible way I have thought of is using the action button, which allows a user in Rulestream's UI to call a function that is in a custom VB file. Thats how it may be possible to get it into the UI.

I was thinking for general methodology though that the best general idea would be for making use of the expression is:

1. Convert the expression to a string.

2. Parse the expression string based on what type of character it contains, such as numbers from operators( +,-, =, etc).

3.  Convert the numbers back to doubles and hold them in variables, and make a case statement that determines what operation to apply based on what type of character is in the expression string that is an operator.

4. Create a scenario to evaluate the equation based on the variables present and operators present.

 

This is just a general idea I came up with so unfortunately I haven't yet really experimented with this , I feel that it may be useful to our group as well to come up with a function for this. Also I'm unsure if there is a way to fire this conversion method automatically, or if it has to be activated by the user each time it needs to be called.

 

Hope this helps,

 

Thanks,

 

Eric Isaacson

Contract Engineer

S&C Electric

www.sandc.com

Re: Evaluate an expression in a rule?

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer

Thanks, Eric. I'm trying to avoid writing an expression parser, if possible. That is my last resort. 

 

Cheers,

Gene

Gene Libardi
Principal Solutions Architect
Engineering Intent Corporation
www.EngineeringIntent.com