# Verify string with comparison/logic operators

**URL:** <https://forum.uipath.com/t/verify-string-with-comparison-logic-operators/402232>\
**Category:** Something Else\
**Tags:** logic-operator, comparison-operator, studio, system\
**Created:** [February 24, 2022, 1:18pm UTC](https://forum.uipath.com/t/verify-string-with-comparison-logic-operators/402232 "2022-02-24T13:18:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinncent\_0](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vinncent_0/32/280005_2.png) [@Vinncent\_0](https://forum.uipath.com/u/Vinncent_0)\
**Post date:** [February 24, 2022, 1:18pm UTC](https://forum.uipath.com/t/verify-string-with-comparison-logic-operators/402232/1 "2022-02-24T13:18:54Z")

</div>

Hi,

(Without using test suite)

Is it possible to verify string expression passing as an input?

The issue is making this dynamic, gathering expression from file and x from app

eg.  
input expression (string) e.g. “x\>5 and x\<=8”  
input parameter x (string)  
result (boolean)

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [February 24, 2022, 1:21pm UTC](https://forum.uipath.com/t/verify-string-with-comparison-logic-operators/402232/2 "2022-02-24T13:21:09Z")

</div>

> [@Vinncent\_0](#):
>
> x\>5 and x\<=8

we would modell as  
`CInt(x) > 5 and CInt(x) <= 8`

A fully functionality like an EVAL() (javascript) we dont have Out-Of-The-Box

But lets loop in @StefanSchnell as maybe we can integrate an inline compilation / execution e.g. with Roslyn and build a EVAL feature by ourself

---

<div class="post-metadata">

**Author:** ![Vinncent\_0](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vinncent_0/32/280005_2.png) [@Vinncent\_0](https://forum.uipath.com/u/Vinncent_0)\
**Post date:** [February 24, 2022, 1:54pm UTC](https://forum.uipath.com/t/verify-string-with-comparison-logic-operators/402232/3 "2022-02-24T13:54:48Z")

</div>

Thanks for info Peter. It would be useful while getting an expression from an input source file. It looks like right now I can only hardcode it

---

<div class="post-metadata">

**Author:** ![StefanSchnell](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/stefanschnell/32/173622_2.png) [@StefanSchnell](https://forum.uipath.com/u/StefanSchnell)\
**Post date:** [February 25, 2022, 7:03am UTC](https://forum.uipath.com/t/verify-string-with-comparison-logic-operators/402232/4 "2022-02-25T07:03:26Z")

</div>

@Vinncent_0

Hello Vinncent,  
here an approach how you can handle your requirement via an Invoke Code activity.  
Best regards  
Stefan

```auto
//-Input Arguments------------------------------------------------------
string condition = "x > 5 && x <= 8";
string variable = "7";

//-Output Arguments-----------------------------------------------------
bool Result;

//-UiPath Invoke Code Activity Begin------------------------------------

string Code = @"
using System;
class Eval {{
  public bool CheckCondition() {{
    int x = {1};
    if({0}) {{
      return true;
    }}
    return false;
  }}
}}";

//-Set condition to {0} and variable to {1}-----------------------------
string code = string.Format(Code, condition, variable);

CodeDomProvider CodeProvider = new CSharpCodeProvider();
CompilerResults CompResult = CodeProvider.CompileAssemblyFromSource(new CompilerParameters(), code);
object oInstance = CompResult.CompiledAssembly.CreateInstance("Eval", false, BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance, null, null, null, null);
MethodInfo MethInfo = oInstance.GetType().GetMethod("CheckCondition");
object oResult = MethInfo.Invoke(oInstance, null);
Result = Convert.ToBoolean(oResult);

//-UiPath Invoke Code Activity End--------------------------------------

```

---

<div class="post-metadata">

**Author:** ![Vinncent\_0](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vinncent_0/32/280005_2.png) [@Vinncent\_0](https://forum.uipath.com/u/Vinncent_0)\
**Post date:** [February 28, 2022, 9:21am UTC](https://forum.uipath.com/t/verify-string-with-comparison-logic-operators/402232/5 "2022-02-28T09:21:56Z")

</div>

Thank you for your engage. In the meantime I found a package from [nuget.org](http://nuget.org) source named “C# Eval Expression | Eval Function” which uses same approach.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [March 3, 2022, 9:22am UTC](https://forum.uipath.com/t/verify-string-with-comparison-logic-operators/402232/6 "2022-03-03T09:22:23Z")

</div>

Closed on March 3, 2022, 9:22am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
