05-15-2009 04:04 PM
Hi all,
I hope someone can help me with a problem i have sending data to a dll.
I have very little knowledge of C, and have accomplished most of the commands i need, except one which is failing to work
I know the C program has the following code
//__declspec(dllimport) int _stdcall OutputPath(int len1, char* Path, int len2, char* Prefix);
char* outpath;
char* prefix;
outpath=".";
prefix="exp75303_TBA_Full_Curve";
ires = OutputPath(sizeof(outpath),outpath,sizeof(prefix),prefix)
Now in LabVIEW i am using the call library function node to set up communication but it keeps falling over on this call (all other calls i can do fine)
I think its my understanding of the sizeof command thats the issue, what exactly is the LabVIEW equivalent, i tried len but have a feeling this is worng as it does not work
Any help will e greatly appreciated
Thanks
Mike
05-15-2009 08:49 PM
05-19-2009 03:56 AM
Mike,
There is a Wikipedia page that explains the function of sizeof. It returns the size in bytes that a variable takes up in memory, in this particular case it returns the number of bytes the array of characters takes up. In LabVIEW the equivalent would be the number of bytes a string uses in memory, andyou can use the String Length function to get this value. The function can be found on the Functions palette under Programming>String>String Length. See also the function Help file.
I am however uncertain that this is causign the problem. When you say the function call does not work, do you get an error code? If so, what? If not, what does happen?
If you could post the DLL and header file, I could take a look at getting this function to work. Also, if you have access to the C code for the DLL, can you find the function OutputPath and see what it does?
Kind regards,
05-19-2009 04:13 AM
Mike,
sadly, the code of the function is not complete in your post.
It calls itself recursivly using the same static parameters after its initial call made by LV. So either there is some tricky code after your excerp or the function is nonsense.
As smercurio already stated, it seems that the function is some kind of concatenation which can be easily done in LV. So please provide the full code of the function OutputPath in order to shed some light on this issue...
hope this helps,
Norbert
05-19-2009 05:20 AM
SheelaS wrote:Mike,
There is a Wikipedia page that explains the function of sizeof. It returns the size in bytes that a variable takes up in memory, in this particular case it returns the number of bytes the array of characters takes up.
That may (or may not) have been the programmers intention, but it is not the situation.
sizeof is a pre-processor operation and not a C function. It requires that the size of a structure / typedef, etc is known a COMPILE time, and gives the "size of" the object in bytes. In this instance sizeof is being applied to two objects that appear to be of type "char *" and will therefore give the size of the POINTER to the string. In general this would be 4 on a machine with 32 bit addressing.
There is a C function to find the length of a string -- strlen ().
As others have said, the code is incomplete - maybe it's the equivalent of "Build Path"? Interestingly the "declaration" line begins with "//" so is a comment. It may just have been put there as a "aide memoire" when writing the call to it, and the code presented is not part of the function.
Rod.
05-19-2009 05:24 AM