greetings :) i believe what you want to store is a pointer to the CPP pointer. im pretty sure as long as your CPP pointer doesnt fall out of scope (making your pointer to it invalid) this should work just fine.
handle_ptr.bmx
handle_ptr.cpp
hope this helps you out :) good luck!
handle_ptr.bmx
Framework BRL.Basic Import "handle_ptr.cpp" Print("in CPP, theValue is initially 22 and theValue2 is initially 33") Print("") Print("retrieving handle pointer...") Local my_ptr:Int Ptr Ptr=getHandlePtr() Print("value of theValue in CPP is: "+my_ptr[0][0]) Print("") Print("changing the value to 99...") setNewValue(99) Print("value of theValue in CPP is now: "+my_ptr[0][0]) Print("") Print("changing the CPP handle pointer to now point to theValue2...") changePtr() Print("value of theValue2 in CPP is: "+my_ptr[0][0]) Print("") Print("setting the value from BMX to 321") my_ptr[0][0]=321 Print("value of theValue2 in CPP is now: ") showOut() Print("") Extern Function getHandlePtr:Int Ptr Ptr() ' returns a pointer to the CPP handle (pointer) Function setNewValue(newVal:Int) ' sets theValue to a new value Function changePtr() ' changes the internal CPP handle to point to theValue2 instead of theValue Function showOut() ' displays the value of theValue2 EndExtern
handle_ptr.cpp
#include "stdio.h" int theValue=22; int theValue2=33; // store a pointer to the first int variable int* handle=&theValue; extern "C" { // returns the handle to the pointer (a pointer to the pointer) int** getHandlePtr() { return &handle; } // sets a new value for the first int variable void setNewValue(int newVal) { theValue=newVal; } // changes to point to the second int variable void changePtr() { handle=&theValue2; } // prints out the value of theValue2 void showOut() { printf("%d",theValue2); } }
hope this helps you out :) good luck!