Kbase 21884: Open Client: Outputting a MEMPTR to Visual Basic
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  13/03/2002 |
|
SUMMARY:
In the 9.1C Open Client it is possible to use MEMPTRS as input/output parameters in procedures that the non-4GL client may call. However if the MEMPTR is used as an output parameter, then a little more work will be required in Visual Basic to capture the returned value.
In this code, running on the AppServer, the output parameter is a MEMPTR which passes back an XML file:
/* MemptrToClient */
define output parameter x as memptr no-undo.
define variable hDoc as handle no-undo.
create x-document hDoc.
hDoc:load( "file", "c:\dlcwork\91b\testdata.xml", false ).
hDoc:save( "memptr", x ).
delete object hDoc.
return.
/* end */
In VB, a MEMPTR comes back as a 'Variant Array of Bytes' so we need to take each byte, convert it to a character, and append it to a string to get the resulting XML document:
Private Sub Command1_Click()
Dim oServer As MemptrProxyLib.CMemptrProxy
Dim xDocument As Variant
Dim cDocument As String
Dim iLoop As Long
Set oServer = New MemptrProxyLib.CMemptrProxy
Call oServer.OC_Connect("AppServer://localhost:5162/asbroker1", "", "", "")
Call oServer.MemptrToClient(xDocument)
Call oServer.OC_Release
Set oServer = Nothing
cDocument = Space(UBound(xDocument) + 1)
For iLoop = LBound(xDocument) To UBound(xDocument)
Mid(cDocument, iLoop + 1, 1) = Chr(xDocument(iLoop))
Next iLoop
End Sub