Forum Discussion

rgratis's avatar
rgratis
Frequent Contributor
13 years ago

Exception trying to access Runtime Objects within same Script Extension

I am writing a Script Extension that contains multiple Runtime Objects for my application, all placed in the same namespace.  Basically, I should have a string property Application.Main.ProcessName.  When I try to access that property inside the Application.Lang runtime object script, I receive an exception and cannot obtain the property.



The error is:

"Object required: 'Application'"

Microsoft VBScript runtime error



The basic setup is attached.  Should I be accessing the object a different way from within the extension?






5 Replies

  • rgratis's avatar
    rgratis
    Frequent Contributor
    I've tried a few different things with this, such as splitting the two objects into separate Script Extensions and removing them from the namespace, but the error persists.



    So, how do I access another script extension from within a script extension?  From what the documentation says, it should be possible...
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    You can access an extension within another extension much as you would any object.  Say I have an extension that creates a runtime object "MyObject1" with a method "MyObjectMethod".  In the script code for another extension, I would simply call



    MyObject1.MyObjectMethod()



    Now, when you start mixing in things like NameSpaces and such that are native to the .NET coding environment and not native to TestComplete and the script extension technology, you're subject to those restrictions and such.  From there, I cannot help you unfortunately.
  • rgratis's avatar
    rgratis
    Frequent Contributor
    Well, just in case, I did try separating the two Runtime Objects out
    into complete separate script extentions with no namespaces.  I still receive the
    same error when trying to call one extension object inside the script of
    another.



    Example: Placing this line in Extension2:

    myVar = Extension1.Property



    Causes an exception when trying to use Extension2 in a script ("Object required: Extension1").



    So it's not the namespace.  Not certain what else to try here... not being able to
    access one object from another pretty much kills the idea of creating an
    application interface in Script Extensions.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    hrm... that's really odd.  I'm not creating application interfaces but I am calling one extension within another.  What it sounds like is that the object name you are calling (in your example Extension1) may not be the name of the object as recognized by the TC engine.  Either the object is not enabled in TC or you've made a mistake in your naming.
  • rgratis's avatar
    rgratis
    Frequent Contributor
    Okay, figured it out!  I had a place where I was trying to set up variables outside the functions in the extension script.  This obviously did not work.  I moved all the variable setup into the initialization routine, where it should be.  Totally my fault.



    Thanks for taking time to look at this, and sorry for any trouble.