Consultor Eletrônico



Kbase P150860: How to copy System.Byte[] to MEMPTR?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/11/2009
Status: Unverified

GOAL:

How to copy System.Byte[] to MEMPTR?

FACT(s) (Environment):

Windows
OpenEdge 10.2A

FIX:

DEF VAR bImg AS MEMPTR.
DEF VAR netArr AS "System.Byte[]".
/* Allocate .NET array with 10 items */
netArr = CAST( System.Array:CreateInstance(
Progress.Util.TypeHelper:GetType( "System.Byte" ), 10 ) , "System.Byte[]" ).
/* move .NET array to MEMPTR */
SET-SIZE( bImg ) = netArr:Length + 1.
REPEAT vi = 0 TO netArr:Length - 1:
/* Currently there is no direct way to copy the data between System.Array and MEMPTR */
/* we need to copy each byte at a time */
PUT-BYTE( bImg, vi + 1 ) = netArr:GetValue(vi) .
END.