Question Better/Elligent way of appending data to a MEMPTR?

Cecil

19+ years progress programming and still learning.
Hi All

I have a crude way of appending data to an existing defined sized MEMPTR by swapping and resizing MEMPTRs. I feel its a bit of a hack without having to dump a MEMPTR to disk and reloading each time.

Is there are better/elligent way of appending data to a MEMPTR?

Code:
DEFINE VARIABLE mpDataTemp  AS MEMPTR  NO-UNDO.
DEFINE VARIABLE mpDataTarget  AS MEMPTR  NO-UNDO.
DEFINE VARIABLE mpDataSwap  AS MEMPTR  NO-UNDO.

SET-SIZE(mpDataSwap) = 0.
SET-SIZE(mpDataSwap) = GET-SIZE(mpDataTarget) + GET-SIZE(mpDataTemp).
           
COPY-LOB FROM OBJECT mpDataTarget TO OBJECT mpDataSwap OVERLAY AT 1.
COPY-LOB FROM OBJECT mpDataTemp   TO OBJECT mpDataSwap OVERLAY AT GET-SIZE(mpDataTarget) + 1.

SET-SIZE(mpDataTarget) = 0
SET-SIZE(mpDataTarget) = GET-SIZE(mpDataSwap).
COPY-LOB FROM OBJECT mpDataSwap TO OBJECT mpDataTarget.

SET-SIZE(mpDataSwap) = 0.
SET-SIZE(mpDataTemp)  = 0.

/** mpDataTarget has now been resized with the new data being appended to it. **/
 
Top