LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sizeof

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

 

0 Kudos
Message 1 of 6
(3,017 Views)
What exactly does OutputPath do? I doubt it's a simple concatenation, since there's already a standard function in the string library to do that. It seems to return an integer, which I assume is an error code.
0 Kudos
Message 2 of 6
(2,993 Views)

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,

Sheela Sujeeun

Applications Engineer
National Instruments UK
0 Kudos
Message 3 of 6
(2,936 Views)

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 6
(2,933 Views)

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.

 

0 Kudos
Message 5 of 6
(2,911 Views)
I stand corrected, thank you Rod.
Sheela Sujeeun

Applications Engineer
National Instruments UK
0 Kudos
Message 6 of 6
(2,909 Views)