passing a string array to an external function

For questions and postings not covered by the other forums
User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

passing a string array to an external function

Postby ghosttie » Tue Sep 11, 2012 4:19 am

I'm trying to create an external function for this method exported by a DLL:

Code: Select all

int gs_main_init_with_args(gs_main_instance * minst, int argc, char *argv[]);
The last parameter is a string array, but I'm not sure how to send that using a JADE external function.

Do I need to use globalAlloc/rtlMoveMemory to create a memory location containing each string and then another one for the array of pointers to those locations?
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: passing a string array to an external function

Postby allistar » Tue Sep 11, 2012 9:30 am

That's a tricky one. You could try geting the memory address of each of the Strings and then create a Binary with the memory addresses padded together. You'll need to work out the size of a MemoryAddress to cater for 32 vs 64 bit.

If this does not work then the approach I would take is create a wrapper external function which takes the inputs in a form more friendly to JADE. Using an external method you could actually pass in a StringArray, though this would prevent you from running it from a thin client - it would have to run on a node. Another option is to pack the Strings together into a single String and then unpack them in the external function. Not nice, but doable.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 15 guests

cron