Forum Discussion

jlegan's avatar
jlegan
New Contributor
15 years ago

"this" keyword undefined in a class method

I have run into an interesting problem. I have a heavily ODT based project in which I dynamically build a test case object on the fly. One of the properties of the object is an array of class objects. Below is a sample (hard coded for illustration purposes).


 


  // Now, populate the test case with the printer object data and install the drivers.


  for (var nPrinterObject in rgPrinterObjects)


  {


    var rgSplitPrinterObject = rgPrinterObjects[nPrinterObject].split("|");


    oTestCase.rgPrinterObjects.AddItemOfClassType("clsPrinterObject");


    oTestCase.rgPrinterObjects(nPrinterObject).sDriverModel = rgSplitPrinterObject[0];


    oTestCase.rgPrinterObjects(nPrinterObject).sInfPath = rgSplitPrinterObject[1];


    oTestCase.rgPrinterObjects(nPrinterObject).sPortType = rgSplitPrinterObject[2];


    oTestCase.rgPrinterObjects(nPrinterObject).sPortAddress = rgSplitPrinterObject[3];


    oTestCase.rgPrinterObjects(nPrinterObject).sPrinterName = rgSplitPrinterObject[4];


    oTestCase.rgPrinterObjects(nPrinterObject).Install();


  }


 


If I break into the debugger, all of the properties of Item0 in my array are set (sDriverModel, sInfPath, etc...). If I break into the code in the Install() method of clsPrinterObject, the "this" keyword is undefined. According to the documentation, what I am doing should work and I am unfortunately blocked from progressing in the implementation until I can get past this.


2 Replies

  • For ODT methods, you should be using "This", with a capital T.
  • jlegan's avatar
    jlegan
    New Contributor
    Tony,



    I saw that in the documentation. However, when I went to implement it, the "intellisense" equiv in TestComplete had "this" as a keyword, not "This". Foolishly, I thought this was a type in the SDK documentation for javascript. I just altered my code to "This" instead of "this" and it is working correctly.



    Thank you for the input. I will file this as an IDE bug with AQA.



    Jim