Copy file content into a String - Forum - OpenEdge General - Progress Community

Copy file content into a String

 Forum

Copy file content into a String

This question is not answered

Hi, I have tried to copy the content of a file into a string with no success. Here is the code:

      copy-lob from file cInputFilePath to textMemPtr.
      xmlString = NEW String(get-string(textMemPtr, 1)).

The content is copied, but incomplete and I don't understand why. If I put the same string directly into a string var
it works, so there is no reason to be a space problem.

Anybody knows how can I solve it?

Thanks in advance.

All Replies
    1. What data type is xmlString?
    2. Does the data in the memptr have embedded null characters in it?
     
     
    Brian Maher
    Principal Engineer, Technical Support
    Progress
    Progress
    14 Oak Park | Bedford, MA 01730 | USA
    phone
    +1 781 280 3075
     
     
    Twitter
    Facebook
    LinkedIn
    Google+
     
     
    ProgressNext2018_Email_Signature
     

  • What data type is xmlString?

    It is a String.

    Does the data in the memptr have embedded null characters in it?

    Maybe, but not at the point where it's cut.

    Is there any other way to move the content to a String?

  • def var xmlString as longchar no-undo.
     
    copy-lob from <blah> to xmlString.
     
     
    Brian Maher
    Principal Engineer, Technical Support
    Progress
    Progress
    14 Oak Park | Bedford, MA 01730 | USA
    phone
    +1 781 280 3075
     
     
    Twitter
    Facebook
    LinkedIn
    Google+
     
     
    ProgressNext2018_Email_Signature
     

  • > On May 15, 2018, at 10:49 AM, untipet wrote:

    >

    > It is a String.

    >

    >

    the 4GL does not have a datatype whose name is String. There are “char” and “longchar”. both are terminated by a null byte, regardless of the character set being used.

  • def var xmlString as longchar no-undo.
    copy-lob from <blah> to xmlString.
     
    It's ok, but I need to translate it to a String var, because the Web Service 'put' metod needs that type as argument. We can do something like:
     
    def var xmlLongchar as longchar no-undo.
    def var xmlString as String no-undo.
    copy-lob from file <blah> to xmlLongchar.
    copy-lob from xmlLongchar  to xmlString.
     
    But when I print it gets cut again and I don't know why. Probably the string var cannot allocate all the required space for the content. Maybe it's a codepage format problem. 
     
    gus bjorklund

    > It is a String.

    the 4GL does not have a datatype whose name is String. There are “char” and “longchar”. both are terminated by a null byte, regardless of the character set being used.

     
    Te 'post' method requires an Object var, so I'm using it for that reason. There is an example:
     
    DEFINE VARIABLE httpUrl AS CHARACTER NO-UNDO.
    DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.
    DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO.
    DEFINE VARIABLE oRequestBody AS String NO-UNDO.
    DEFINE VARIABLE oJsonEntity AS JsonObject NO-UNDO.
    DEFINE VARIABLE JsonString AS LONGCHAR NO-UNDO.

    SESSION:DEBUG-ALERT = TRUE.
    httpUrl = "www.googleapis.com/.../token".

    oRequestBody = new String('client_id=your_client_id&client_secret=your_client_secret&refresh_token=your_refresh_token&grant_type=refresh_token').

    oRequest = RequestBuilder:Post("www.googleapis.com/.../token", oRequestBody)
    :ContentType('application/x-www-form-urlencoded')
    :AcceptJson()
    :Request.
    Thanks for the answers
  • @Gus, OE may not have a String primitive, but there is such a thing as the OpenEdge.Core.String class (which comes out of OpenEdge.Core.pl).

  • Do think this and everything else that can be packed as some kind of SDK will be better of if released as a public project on github, Peter might use some help from community ;)

    Marian Edu

    Acorn IT 
    +40 740 036 212

  • > On May 16, 2018, at 4:37 AM, bronco wrote:

    >

    > @Gus, OE may not have a String primitive, but there is such a thing as the OpenEdge.Core.String class (which comes out of OpenEdge.Core.pl).

    Is there doc on OpenEdge.Core.pl, its contents, and usage someplace? I couldn’t find it. Maybe I didn’t look hard enough.

  • Actually there is something in OE Help but it eventually ends-up pointing to this online documentation - documentation.progress.com/.../index.html 

    Nowadays automatically generated 'documentation' seems to be good enough ;)
      
    Marian Edu

    Acorn IT 
    +40 740 036 212

  • marian.edu
    Nowadays automatically generated 'documentation' seems to be good enough ;)

    Guess how nice it would have been if the author of that code would have followed coding standards that include documentation standards ... I must be dreaming. 

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.


  • Speechless, Marian?

    Sent from Nine

    Von: "marian.edu" <bounce-marianedu@community.progress.com>
    Gesendet: Mittwoch, 16. Mai 2018 17:02
    An: TU.OE.General@community.progress.com
    Betreff: RE: [Technical Users - OE General] Copy file content into a String

    Update from Progress Community
    marian.edu


    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • > On May 16, 2018, at 10:38 AM, marian.edu wrote:

    >

    > Actually there is something in OE Help but it eventually ends-up pointing to this online documentation - documentation.progress.com/.../index.html

    >

    >

    guess at PSC there must be at least one person who thinks that is documentation.

  • -I- , er the author, prefers not to shout at their readers. ;)
     
     
     
  • That's probably just a feature of the community's 'bulletin board system'... trying to quote you my reply was 'not everyone is perfect' but guess that really equals to being speechless :)

    Marian Edu

    Acorn IT 
    +40 740 036 212