01-01-2016 01:12 AM
Hi sir
I want to pass array of two dimensional f string data to LabVIEW from CVI build dll.I have example code VI and DLL for passing one dimensional array of data to LabVIEW.Please make the correction in the code of array of data to pass in LabVIEW
The prasent CVI Code as shown below
/* Call Library Source File */
#include "extcode.h"
_declspec(dllexport) void StringTest(char cstr[],char ByteArray[],long ByteArrayLength,LStrHandle lstr);
_declspec(dllexport) void StringTest(char cstr[],char ByteArray[],long ByteArrayLength, LStrHandle lstr)
{
char temp[39] = "I have modified the string in the DLL!";
int templength = 0;
MgErr err;
/* NULL character should be the 26 character in the string (index 25) */
/* Cstr should be cut off in returning to LabVIEW */
/* ByteArray will not be cut off */
/* Modify the LabVIEW String Handle and send it back */
templength = StrLen(temp);
err = DSSetHandleSize(lstr, sizeof(char) * templength + 4);
if(err != noErr)
{
return; /* Memory issue */
}
(*lstr)->cnt = templength;
MoveBlock((&temp),(*lstr)->str, (*lstr)->cnt);
}
Its working fine for this single array data.
I have modified Preasent CVI code with mulitiple array data,but not getting the Correct data,Please make correction in CVI as well as VI
attached below.
/* Call Library Source File */
#include "extcode.h"
_declspec(dllexport) void StringTest(char cstr[],char ByteArray[],long ByteArrayLength,LStrHandle lstr);
_declspec(dllexport) void StringTest(char cstr[],char ByteArray[],long ByteArrayLength, LStrHandle lstr)
{
char Strings[39][40] = {"one" , "two" , "three , "four" , "five" , "Six', "Seven" ,"Eight" , "Nine" , "ten" }
int templength = 0;
MgErr err;
/* NULL character should be the 26 character in the string (index 25) */
/* Cstr should be cut off in returning to LabVIEW */
/* ByteArray will not be cut off */
/* Modify the LabVIEW String Handle and send it back */
for(i=o;i<=10;i++)
templength = StrLen( Strings[i]);
err = DSSetHandleSize(lstr, sizeof(char) * templength + 4);
if(err != noErr)
{
return; /* Memory issue */
}
(*lstr)->cnt = templength;
MoveBlock((& Strings[i]),(*lstr)->str, (*lstr)->cnt);
}
01-01-2016 02:32 AM