I have a MEMPTR which contains 40000 characters. I would like to retrieve those chars into a char variable, which is impossible with a standard CHAR var (limit : 32k). That's why I use a LONGCHAR.
The following code works, but I think there is a better way to do it.
Any idea ?
Thanks in advance.
Julien
The following code works, but I think there is a better way to do it.
Code:
DEF VAR ptr AS MEMPTR NO-UNDO.
DEF VAR str AS CHAR NO-UNDO.
DEF VAR str2 AS CHAR NO-UNDO.
DEF VAR strSize AS INT NO-UNDO.
DEF VAR bigStr AS LONGCHAR NO-UNDO.
DEF VAR i AS INT NO-UNDO.
/* Put 40000 chars into the MEMPTR */
DO i = 1 TO 2000 :
str = str + "0123456789".
END.
SET-SIZE(ptr) = 0.
strSize = LENGTH(str).
SET-SIZE(ptr) = 2 * strSize + 1.
PUT-STRING(ptr,1) = str.
PUT-STRING(ptr,strSize + 1) = str.
/* Copy MEMPTR into LONGCHAR */
COPY-LOB FROM ptr STARTING AT 1 FOR (2 * strSize) TO bigStr.
DISP LENGTH(bigStr).
Any idea ?
Thanks in advance.
Julien