Options

Converting big text to stream

kamranshehzadkamranshehzad Member Posts: 165
Is it possible to convert big text to inStream? I dont want to write into a file and then read from it.

Please help.

regards,
KS

Answers

  • Options
    ara3nara3n Member Posts: 9,255
    Yes
    table.BlobField.CREATEOUTSTREAM(ostream);
    bstr.WRITE(ostream);
    

    table.BlobField.CREATEINSTREAM(istream);
    bstr.READ(istream);
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    kamranshehzadkamranshehzad Member Posts: 165
    Thanks.

    But I have got a text variable.

    lets say "txtA" being passed from some other source to a function
    Now I want to load it into a stream to pass it xml port.

    so what needs to be done.

    txtA.CREATEINSTREAM(ostream);
    bstr.READ(istream);

    right?
    KS
  • Options
    DenSterDenSter Member Posts: 8,304
    There's a table that you can use for this purpose, called TempBLOB. Add a temporary record variable based on that table, and use its methods:
    TempBlob.Blob.CREATEOUTSTREAM(outstr);
    TempBlob.Blob.CREATEINSTREAM(instr);
    
    Now you can use other automation to actually populate the out and instreams. Read the outstream from a big text, and use the outstream as the source for your XMLPort.

    You would use CREATEOUTSTREAM only for outstreams, not instreams. For that you would use CREATEINSTREAM. By using the TempBlob table, when you read the instream into the Blob field, you can set its value from an instream, and use it to create an outstream, based on the same field.
  • Options
    kamranshehzadkamranshehzad Member Posts: 165
    hI thanks for your help.
    I am just new to nav cal coding...


    ProcessCustomers(InputXML : BigText) status : Boolean

    tempRec.Blob.CREATEINSTREAM(XMLInStream);
    InputXML.READ(XMLInStream);
    XMLPORT.IMPORT(123456751,XMLInStream);
    status := TRUE;

    not getting the data into the table through XMLPORT.

    Am i still doing any thing wrong?

    please advise.

    regards,
    KS
  • Options
    kinekine Member Posts: 12,562
    Yes, you are reading the blob into the BigText instead writing it into outstream and reading it through instream...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    kamranshehzadkamranshehzad Member Posts: 165
    OOOOOOOOOOOOOOOOPPPS! done. thank you very much.

    regards,
    KS
  • Options
    kinekine Member Posts: 12,562
    You are welcome... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.