Forum Discussion

Cujo's avatar
Cujo
Occasional Contributor
7 years ago

Need help understanding testcomplete vbscript code

I am looking through some existing code. What does this below piece code means? what exactly eval is doing here? i read that eval is used to evaluate any expression.    Public Function Perform(modu...
  • shankar_r's avatar
    7 years ago

    I can give you an example with the code you are having.

     

    Assume you code in Unit1

     

    'Run the testit function
    Public Function testit Call Perform("Unit1.testmyCode", "hi", "hello") End Function Public Function testmyCode(param1,param2) Log.Message("This is param 1 - " & param1) Log.Message("This is param 2 - " & param2) End Function Public Function Perform(moduleCode, input, output) Perform = eval(moduleCode & "(input, output)") End Function

    You will get output as below,

     

    This is param 1 - hi 11:55:22 Normal 0.00
    This is param 2 - hello 11:55:22 Normal 0.05