memptr as function parameter

Boomn4x4

New Member
I have a function setup as:
PROCEDURE msgi_request_reply EXTERNAL {&libmsgi} CDECL PERSISTENT :
define input parameter requestDestType as character. /* 'QUEUE' or 'TOPIC'*/
define input parameter requestDestination as character. /* name of queue or topic */
define input parameter requestString as character. /* message byte buffer (UTF-8) string */
define input parameter requestLength as long. /* Length of message in bytes */
define output parameter replyBuffer as memptr. /* Caller-allocated buffer to hold the reply */
define input parameter replyBufLen as long. /* Max size of reply (size of replyBuffer) */
define output parameter replyActualLen as long. /* how the the reply actually was */
define input parameter timeoutMillis as long. /* How many milliseconds to wait for reply */
define return parameter returnStatus as long. /* Integer with status info. 0 = success */
END PROCEDURE.

I've got variables defined in the program as:
def var destType as char initial 'QUEUE'
def var queueName as char initial 'MY_QUEUE'
def var msg as char initial 'my message'
def var repBuf as memptr.
def var rv as integer initial -1

I'm calling the procedure as:
run msgi_request_reply(destType, queueName, msg, length(msg), repBuf, 50, 50, 100, OUTPUT rv)

when I run it, I'm getting a mismatched parameter type.

I am assuming that it has to do with the memptr... and my lack of understanding how to use them in Progress, but I don't know where to go from here. Any help would be appreciated.
 

GregTomkins

Active Member
I'm not familiar with DLL's with Progress but we use MEMPTR all the time (mostly but not solely across the AppServer boundary) and I don't think it has any particular complications as long as the data types match up in the normal way. It looks like you have OUTPUT parameters that are not passed as such, though (repBuf and replyActualLen).
 

Marian EDU

Member
Caller-allocated buffer to hold the reply

that leads me into thinking that you (the caller) need to allocate memory for that memptr and hence it shouldn't be neither defined as output but input and when you pass it it most probably need to get the pointer (as a long) instead of the memptr variable.


Code:
PROCEDURE msgi_request_reply EXTERNAL {&libmsgi} CDECL PERSISTENT :
  define input parameter requestDestType as character. /* 'QUEUE' or 'TOPIC'*/
  define input parameter requestDestination as character. /* name of queue or topic */
  define input parameter requestString as character. /* message byte buffer (UTF-8) string */
  define input parameter requestLength as long. /* Length of message in bytes */
  define input parameter replyBuffer as long. /* Caller-allocated buffer to hold the reply */
  define input parameter replyBufLen as long. /* Max size of reply (size of replyBuffer) */
  define output parameter replyActualLen as long. /* how the the reply actually was */
  define input parameter timeoutMillis as long. /* How many milliseconds to wait for reply */
  define return parameter returnStatus as long. /* Integer with status info. 0 = success */
END PROCEDURE. 

def var destType as char initial 'QUEUE'
def var queueName as char initial 'MY_QUEUE'
def var msg as char initial 'my message'
def var repBuf as memptr.
def var rv as integer initial -1

set-size(repBuf) = 50.
run msgi_request_reply(destType, queueName, msg, length(msg), get-pointer-value(repBuf), 50, 50, 100, OUTPUT rv).

p.s. don't forget to do the clean-up when you've done with that buffer - set-size(repBuf) = 0.
 
Top