On Jun 8, 2006, at 10:44 PM, Norman Palardy wrote:
I have a function in a library I'm trying to call and it has a
parameter that is a ** param
the function is like this
int f(Msg **res)
So I thought I'd declare it like
soft declare function f lib "mylib" (Byref res as Ptr ) as integer
and call it like
const kSuccess = 0
dim mb2 as new MemoryBlock(4)
dim results as new MemoryBlock(4)
mb2.Ptr(0) = results
if f( mb2 ) = kSUCCESS then
This fails because you're passing a memoryblock, not a Ptr. The
MemoryBlock is converted to a Ptr, and if REALbasic allowed passing the
result byref, it wouldn't behave as you'd hope -- the temporary
variable would be passed byref, not the Ptr that the MemoryBlock
contained.
However, it appears you've set this up properly except for specifying
Byref in the declare statement. By linking one memoryblock to another
using Ptr(), you're creating the extra "byref" yourself. That's the
proper way to handle this situation. So, simply removing Byref should
work.
HTH,
Jon
--
Jonathan Johnson
REAL Software, Inc.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>