Forum Discussion

tobello's avatar
tobello
Contributor
11 years ago

Eval returns 'Expected Object Error'

Hello



I'm trying to call a routine using the JScript Eval Method but I'm always getting an exception:

Here's what I'm tryng to do:

In the same unit, I have my main function defined as:


function AddClassifMultipleLocations(WorkSheetName)

{

 
var testFile = Project.Variables.TestFilePath;

  var page, menu, menuLink, validSum;

  var isExpectedErrorMsg = true;



  // Creates a driver

  var multDataEntry = DDT.ExcelDriver(testFile, WorkSheetName);



  try

  {

    // Test actionS to perform using input from Worksheet

    ...

  }

}//End function





Then I test the above function using the Eval:



function Test_AddClassifMultipleLocations()

{

  try

  {

    var strFunc = "AddClassifMultipleLocations" + "(\"" + "DFE4_AddLocations" + "\");";

    var result = Eval(strFunc);

  }

  catch(e)

  {

    Log.Error(e.description);

  }

}



but I'm alway getting an exception as of 'Object expected ...'



I cannot see where I screwed... Plz assist...



Regards


2 Replies

  • Hi there,

    Oh Geeeez, Screw me...!!!



    I finally figure it out...

    The issue was calling Eval(...) instead of eval(...)

    function Test_AddClassifMultipleLocations()

    {

      [...] 

      //var result = Eval(strFunc);

      var result = eval(strFunc);

      [...]

    }


  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    <Removed as Ted found what was the problem while I wrote my reply :) >