Forum Discussion

fujunxu's avatar
fujunxu
Contributor
9 years ago

There is one method(open application) return an object which is string how can I get the string ?

I am testing an open application.  one of the method called GetStringValue_1.  It return a object which is a string.  How can I get the string value in my script.  Thanks!

  • CStrings should have the m_pszData field that contains the actual string. You may need to switch to the advanced view to see it.

     

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    If it's a .NET, WPF, Silverlight or Java application, apply .OleValue to the string object:

    str = obj.GetStringValue_1().OleValue

    In other application types, VarToStr(obj) might work.

    • fujunxu's avatar
      fujunxu
      Contributor

      Thank your for your information.  It is a C++ application.   I got empty string when I used VarToStr(obj).

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        It's hard to tell without seeing your application. Do you know how the method signature looks in the application code? There are some limitations on native method calls, for example, returning values via reference parameters is not supported.

         

        If you got a valid object as a result, inspect it in the Ctrl+F12 window (make sure to turn on the Show hidden members option in Tools > Options > Engines > General). There might be a property or method to access individual characters/bytes of the string, or something similar.