Handling long strings returned from COM Objects

ta5ta5 Member Posts: 1,164
Hi

I have a question which was in parts discussed in http://www.mibuso.com/forum/viewtopic.php?t=7980

There is a COM object which returns a long text (bstr). When using
myStr := myCom.TextData the ffw error occurs:
"The length of the text string exceeds the size of the string buffer."

This is in Navision 4.0, so I thought I could work around with a bigtext variable, but the same problem there.
myBigText.ADDTEXT.. does not work for the same reason and
myBigTxt.READ needs a Stream as input.

BTW, changing the COM object is not an option. :(

Any comments or workaround on this will be appreciated.
Thanks
Thomas

Comments

  • wonmowonmo Member Posts: 139
    Depending on what you want to do with the long text use the instream and/or the outstream variable types. I had the same error when trying to write to a file and using the outstream variable type solved it.
  • ta5ta5 Member Posts: 1,164
    Can I use instream when the return value of the com object is bstr?
    Do you have a code sample for this?
  • ta5ta5 Member Posts: 1,164
    Any other ideas?

    Btw: In the meantime I developed a kind of a helper dll, which first receives the whole automation object from navision (by a method a) and then returns chunks of the long text back to navision (by a method b). This works quite ok, but is IMHO too complex to use on a regular basis.
  • DakkonDakkon Member Posts: 192
    I do believe the problem is that Navision still marshals all string data going to and from a COM object as a 250 char text data type. So even if the variable you are assigning to can hold more, Navision still attempts to convert it to a 250 max text variable before doing the actual assignment.
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • ta5ta5 Member Posts: 1,164
    I sadly came to the same conclusion :shock:
    Thank you very much for your feedback.
    Thomas
  • DakkonDakkon Member Posts: 192
    I did something fairly similar as far as a helper object. I created a dynamic string array class object. I use it to package string data back and forth from Navision and my COM objects.
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • ara3nara3n Member Posts: 9,257
    I had to write a wrapper in VB that would split the text and send it separately. So that would work.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • markvandermeijmarkvandermeij Member Posts: 26
    Have you tried to handle it as a variant and then converting into a string in Navision?
  • ta5ta5 Member Posts: 1,164
    Yep, but no success
  • ara3nara3n Member Posts: 9,257
    there is no workaround. you have to write a wrapper in VB.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.