cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Charlie_Chu
Level I

How to call DLL function with String Array and receive Double Array data?

I had read the content of charter 14 in scripting guide, and did some test about my C function.
The attachment testdll.jsl works fine with simple data, like AnsiString (in and out). In the log I can see:

---
dll_obj = DLL("C:\Users\charlie.chu\Documents\JMP\JSL\jmptest2.dll");
[CDECL] AnsiString testFunc(AnsiString);
result = "ABC";
---
My question is, if I want to sent data like {"1.2, 2.3, 3.4", "5.6, 6.7, 7.8"}, and finally recieve the return data like { {1.2, 2.3, 3.4} , {5.6, 6.7, 7.8} }. How should I do? I can not find a suitable data type.

In the C code, the function strSplit is defined with

double** strSplit(char** strArray) {

I can not use AnsiString, but ObjPtr is also failed. 
PS: I found the c language code can not be an attachment file.....

 
4 REPLIES 4
jthi
Super User

Re: How to call DLL function with String Array and receive Double Array data?

CharlieChu
Level I

Re: How to call DLL function with String Array and receive Double Array data?

Thanks. So the conclusion is: No solution so far.
I will try send data from JMP with TCPIP socket instead of calling DLL function, it will be obviously slower... 

Charlie Chu
peng_liu
Staff

Re: How to call DLL function with String Array and receive Double Array data?

Maybe try repackaging your arguments before sending to your C codes:

1) A long string, which is a concatenation of all your string

2) A numerical array, elements record either the lengths of individual strings, or offsets of individual string

And your C codes need to unpack them.

pmroz
Super User

Re: How to call DLL function with String Array and receive Double Array data?

If your objective is to convert your string to a list of lists, you could do that in JSL.  Here are two approaches:

// Given this string:
a = {"1.2, 2.3, 3.4", "5.6, 6.7, 7.8"};

// Return data like { {1.2, 2.3, 3.4} , {5.6, 6.7, 7.8} }

// Parse things apart
new_list = {};
m = 0;

for (i = 1, i <= nitems(a), i++,
	one_list = words(a[i], ", ");
	for (k = 1, k <= nitems(one_list), k++,
		one_list[k] = num(one_list[k]);
	);
	m++;
	new_list[m] = one_list;
);

print(new_list);

// Use matrix operators
exec_string = "new_mat = matrix({";
for (i = 1, i <= nitems(a), i++,
	if (i == 1,
		exec_string = exec_string || "{" || a[i] || "}";
	,
		exec_string = exec_string || ", {" || a[i] || "}";
	);
);

exec_string = exec_string || "})";
eval(parse(exec_string));

print(new_mat);

The first one returns:

{{1.2, 2.3, 3.4}, {5.6, 6.7, 7.8}}

The second one returns a matrix:

[1.2 2.3 3.4, 5.6 6.7 7.8]