Options

BSTRConverter doesn't seem to work and I've ran out of ideas

Miklos_HollenderMiklos_Hollender Member Posts: 1,598
edited 2009-12-02 in NAV Three Tier
Hello,

I have a Third Party OCX Component (used for a kind of reporting) I should call like for example:
TPComponent.DefineVariableExt('Customer.Balance', FORMAT(Cust.Balance), TPConst('NUMERIC_LOCALIZED'));

Variable name, value converted to text, type. Easy.

Now imagine passing instead of FORMAT(Cust.Balance), say, 5000 characters of (non-XML) text I store in a BLOB field...

I've tried the following:
   CLEAR(BigTextVar);
   CLEAR(InS);
   Cust.CALCFIELDS(Cust."BLOBField");
   Cust."BLOBfield".CREATEINSTREAM(InS);
   BigTextVar.READ(InS);
  
   
   //it's just an example, I'm to tired at 19:15 to write out the loop for it's sake, just imagine the loop here :)))
   bcon.ResetBSTR;
   CLEAR(t1000);
   BT.GETSUBTEXT(t1000,1,1000);
   bcon.AppendNextStringPortion(t1000);

   CLEAR(t1000);
   BT.GETSUBTEXT(t1000,1000,1000);
   bcon.AppendNextStringPortion(t1000);

   CLEAR(t1000);
   BT.GETSUBTEXT(t1000,2000,1000);
   bcon.AppendNextStringPortion(t1000);

   TPComponent.DefineVariableExt('LongBigYadaYada',bcon.BSTR, TPConst('TP_TEXT'));

I get a string buffer error at the last line.

Isn't it exactly what this converter is for? Any ideas?

Comments

  • Options
    ara3nara3n Member Posts: 9,255
    COM interfaces are still limited at 1024.

    I know there are some post that mention this automation as a solution, but it's false.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    COM interfaces are limited to 1024 from the classic client yes.

    If you use RTC or Web Services you can use BigText directly as a parameter to a method expecting a string - and you can get things from a method returning a string of any length adding that to a BigText in ADDTEXT.

    http://blogs.msdn.com/freddyk/archive/2008/11/04/transferring-data-to-from-com-automation-objects-and-webservices.aspx
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • Options
    Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Thanks but the solution I'm building needs to support both clients, for a few years at least.

    The basic problem is that this OCX only accepts BSTR parameters which NAV understands as text. Freddy, is there any special reason why NAV refuses to give a BigText variable to an OCX that expects a BSTR - what is a BigText internally, if not a BSTR?

    And this OCX cannot read a stream, nor a file, nor has it a method that would add to the variable instead of overwriting it...

    I suppose it would be the same trying to force it into XMLDOM...

    Would it be possible to write a .NET OCX object that would take the instance of the non-.NET OCX object I'm struggling with plus a BigText variable or InStream or whatever and would feed the later into a method of the former? If yes could someone give a rough sketch of pseudocode how?

    Any other ideas? Thx.
  • Options
    ara3nara3n Member Posts: 9,255
    you have to write a wrapper dll using vb or any .net language and use that dll in in nav.
    Ahmed Rashed Amini
    Independent Consultant/Developer


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