Ravi
Ravi

Reputation: 31

How to Copy MEMPTR to/from a LONGCHAR variable with out getting error or NULL value?

while copying the value of a MEMPTR to a LONGCHAR variable using GET-STRING, i got an error 9324 . Is there any solution ?

I've tried this:

function x returns longchar():
  DEF VAR i_xml_string AS LONGCHAR NO-UNDO.
  DEF VAR i_mem        AS MEMPTR   NO-UNDO.
  p_doc:SAVE("memptr":U, i_mem).
  COPY-LOB FROM i_mem TO i_xml_string.
  return i_xml_string.
end.

But got the following errors:

[16/03/17@10:20:58.984-0700] P-009824 T-000001 3 4GL 4GLTRACE Return from ConvertXmlDocToLongString "" [yeai/ye508mu.p] [16/03/17@10:20:58.984-0700] P009824 T-000001 1 4GL -- (Procedure: 'GenerateT5008xmlCusipSummaryRecordyeai/ye508mu.p' Line:2536) Attempt to exceed maximum size of a CHARACTER variable. (9324) [16/03/17@10:20:58.984-0700] P-009824 T-000001 1 4GL -- (Procedure: 'GenerateT5008xmlCusipSummaryRecord yeai/ye508mu.p' Line:2536) ** Unable to evaluate expression for PUT statement. (564) [16/03/17@10:20:58.984-0700] P009824 T-000001 3 4GL 4GLTRACE Return from GenerateT5008xmlCusipSummaryRecord "? tmp_cusip_tots yes " [yeai/ye508mu.p]

Upvotes: 2

Views: 3207

Answers (2)

Marcel
Marcel

Reputation: 1

As definitely not solved, use the following:

DEF VAR Z64 AS MEMPTR.
DEF VAR A AS LONGCHAR.
DEF VAR Z AS CHAR.

DEF VAR size64  AS INT.
SET-SIZE(Z64) = 200000.  /* base64is a function of vpxPrint */
  RUN base64("e:/temp/XXXX.jpg", Z64, 10, OUTPUT size64). /* get the size */
MESSAGE "base64 string length" size64 VIEW-AS ALERT-BOX.
  RUN base64("e:/temp/XXXX.jpg", Z64, 200000, OUTPUT size64).

DEF VAR i AS INT.
DEF VAR j AS INT.
DEF VAR lastSegment AS INT.

/* Segments of 30.000 bytes (PROGRESS limit)  */

j = TRUNC(size64 / 30000, 0).
IF j MOD 30000 <> 0 THEN DO:
        j = j + 1.
        lastSegment = size64 MOD 30000.
        END.
ELSE
        lastSegment = 30000.

DO i = 1 TO j:                                      
                    Z = GET-STRING(Z64, (i - 1) * 30000 + 1, 
                                   (IF i = j THEN lastSegment ELSE 30000)).                     
                    A = A + Z.
                    END.

SET-SIZE(z64) = 0.

/* LONGCHAR "A"   contains the string!
   ===================================*/

Upvotes: -1

Tom Bascom
Tom Bascom

Reputation: 14020

GET-STRING operates on ordinary character strings. Those are limited in size to around 31,000 bytes. Use COPY-LOB to to get MEMPTR data in and out of LONGCHAR.

Something like:

copy-lob from my_memptr to my_longchar.

PUT is also restricted to ordinary CHAR strings. If you want to work with LONGCHAR and MEMPTR you need to use COPY-LOB.

Upvotes: 2

Related Questions