Consultor Eletrônico



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

GOAL:

How to copy MEMPTR to System.Array[]?

FACT(s) (Environment):

OpenEdge 10.2A
Windows

FIX:

DEF VAR mptr AS MEMPTR.
DEF VAR bytes AS "System.Byte[]".
DEF VAR vi AS INT.
DEF VAR ibyte AS INTEGER.

SET-SIZE( mptr ) = 11.
PUT-STRING( mptr, 1 ) = "0123456789".

bytes = CAST( System.Array:CreateInstance(
Progress.Util.TypeHelper:GetType( "System.Byte" ), 10 ) , "System.Byte[]" ).

DO vi = 1 TO GET-SIZE( mptr ) - 1:
ibyte = GET-BYTE( mptr, vi ).
bytes:SetValue( BOX( ibyte, "SHORT" ) , vi - 1 ).
END.