Options

How to handle text of length more than 1024

ajaybabuChajaybabuCh Member Posts: 208
Hi

I have registered a dll to Navision. One of dll's function is returning the text more than 1024 length.
How to handle this situation.

Here is the code which I tried

Var Name Type subtype
AutomationVar Automation which will point to my new registered dll
BigTextVar BigText

Code :

BigTextVar.AddText(AutomationVar.GetText());
//AutomationVar.GetText() getting text more than 1024 characters.


here I am getting the error "length of the text string is exceeds size of the bugger.

is there any way to handle this situation
Ajay

Comments

  • Options
    ajaybabuChajaybabuCh Member Posts: 208
    Actually the text which is coming in is in xml format, I also tried the following code

    XMLDom.loadXML(AutomationVar.GetText());

    Where XMLDom is of type 'Microsoft XML, v3.0'.DOMDocument'

    still getting the same error "length of the text string is exceeds size of the buffer"


    any idea on this
    Ajay
  • Options
    ajaybabuChajaybabuCh Member Posts: 208
    any guess on this
    Ajay
  • Options
    kinekine Member Posts: 12,562
    If the return value of GetText is resolved in NAV as Text datatype, you have the 1024 bytes limit regardless how you will use the function. If there is no other way how to read the data, you will need to do some wrapper library around that which will read the text and you will be able to read this text through Stream o part by part.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    bluesky29bluesky29 Member Posts: 29
    you can use the NATHash.dll from Navision to receive Strings > 1024 characters

    while i'm not in office this time i post the code later

    Regards,
    Markus
  • Options
    ara3nara3n Member Posts: 9,256
    bluesky29 wrote:
    you can use the NATHash.dll from Navision to receive Strings > 1024 characters

    while i'm not in office this time i post the code later

    Regards,
    Markus

    I don't think it's possible unless you use 2009 RTL with variant type. But I would like to see it.

    if isclear(xmldom) then
      create(xmldom);
    
    if isclear(NATHash) then
      create(NATHash);
    
    xmldom.async := false;
    
    xmldom.load('C:\xmlfile.xml');
    
    
    NATHash.BSTR(xmldom.text);
    

    The last line above will still error out.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    bluesky29bluesky29 Member Posts: 29
    here ist the code:

    XlRange := XlWrkSht.Range('A1').SpecialCells(11);
    Maxi := XlRange.Row;
    Maxj := XlRange.Column;
    i := FirstRowNo;
    REPEAT
    j := 1;
    xlRowID := FORMAT(i);
    REPEAT
    xlColID := GetExcelColumn(j);
    CASE xlColID OF
    'K' : BEGIN
    CREATE(bcon);
    y := 1;
    x := 0;
    bcon.BSTR(XlWrkSht.Range(xlColID + xlRowID).Value);
    WHILE x < bcon.GetBSTRLength DO BEGIN
    bcon.GetNextStringPortion(ImpExtText[y],1024);
    x += 1024;
    y +=1;
    END;
    CLEAR(bcon);
    END;

    we use excel to import nonstock item text. this works.
    Maybe you need to import the value of a single field of the xml
  • Options
    ara3nara3n Member Posts: 9,256
    I would have to say that the following code
    bcon.BSTR(XlWrkSht.Range(xlColID + xlRowID).Value);
    


    would error if the cell has more than 1024 characters.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    bluesky29bluesky29 Member Posts: 29
    i've tested this with 5.0 Client

    works fine - no error
  • Options
    ara3nara3n Member Posts: 9,256
    I've tested with 5.0 sp1 and 2009.
    Ahmed Rashed Amini
    Independent Consultant/Developer


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