Copy file content into a String

Posted by untipet on 15-May-2018 09:07

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

Posted by Brian K. Maher on 15-May-2018 09:16

  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
 

Posted by untipet on 15-May-2018 09:48

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?

Posted by Brian K. Maher on 15-May-2018 10:36

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
 

Posted by gus bjorklund on 15-May-2018 14:20

> 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.

Posted by untipet on 16-May-2018 02:36

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. 
 
[quote user="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.

[/quote]
 
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

Posted by bronco on 16-May-2018 03:36

@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).

Posted by marian.edu on 16-May-2018 03:44

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

Posted by gus bjorklund on 16-May-2018 09:08

> 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.

Posted by marian.edu on 16-May-2018 09:36

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

Posted by Mike Fechner on 16-May-2018 09:45

[quote user="marian.edu"]

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

[/quote]

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. 

Posted by marian.edu on 16-May-2018 10:00


Posted by Mike Fechner on 16-May-2018 10:04

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.

Posted by gus bjorklund on 16-May-2018 11:00

> 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.

Posted by Peter Judge on 16-May-2018 11:36

-I- , er the author, prefers not to shout at their readers. ;)
 
 
 

Posted by marian.edu on 16-May-2018 11:52

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

This thread is closed