LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[HELP] Call Library Function Node...

Solved!
Go to solution

I cannot get the LStrPrintf version to work at all it just crashes LabView.

 

I do have a BlockMove version (see attachment), but it only seems to get the first 10 characters of the string if there are spaces in it.  If I change my test DLL string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" I get the lot out????

Christopher Povey

Principle Test Systems Engineer for BAE Systems.
0 Kudos
Message 11 of 16
(1,063 Views)

Smiley Very Happy

 

Fixed it.  I managed to get LStrPrintf to work...

 

Thanks all.

Christopher Povey

Principle Test Systems Engineer for BAE Systems.
0 Kudos
Message 12 of 16
(1,054 Views)

ChristopherPovey wrote:

And parameter 3 is:

 

Type: Numeric

Data Type: Signed 8-bit Integer

Pass: Pointer to Value

 

???

 

Also the "problem" DLL function.  Should that be set up as per "this little trick"?

 

Thanks.


Well LabVIEW 8.5 does not have pointer sized integers. So you will want to use a 32 Bit integer and set Pass: Value.

 

For your own DLL you will want to set it to Pass: Pointer to Value

Rolf Kalbermatter
My Blog
0 Kudos
Message 13 of 16
(1,046 Views)

Rolf,

 

Thank you for your answer to the original question.  It just helped me too -- I came here with the same question, searching for a solution.

 

Just one note.  You wrote: "As such the function will allocate a pointer and return it (a highly non-standard C practice at least for strings). This automatically begs the question when and how will this pointer be deallocated?".

 

This is not completely true.  The same prototype is often used in a different, quite standard C practice.  Often for things like retrieving an error string by code, or some such.  The strings are constant strings, and they are returned either via a "char *" return value or via a "char **" parameter, where nothing is allocated, and nothing needs to be deallocated.  The user's pointer is simply pointed to the constant string.

 

eg:

 

void GetErrorString(int errorCode, char **ppErrorString) {

    switch (errorCode)  {
          case error1:
               *ppErrorString = "Error 1 occured");

                return;
          case error2:
              *ppErrorString = "Error 2 occured");
                return;
          default:
               "Unknown error";

    }

}

 

or, more common:

 

char * GetErrorString(int errorCode) {

    switch (errorCode) {
         case error1:
             return "error 1 occured";
         case error2:
             return "error 2 occured";
         default:
             return "Unknown error";
    }

}

 

Batya

0 Kudos
Message 14 of 16
(857 Views)

You are of course right with this. However the fact that the returned pointer is really a static memory location should be just as much documented as if it would be dynamic. C simply isn't verbose enough in itself to allow this indication, and assuming that no documentation means static memory is really a dangerous one.

Rolf Kalbermatter
My Blog
0 Kudos
Message 15 of 16
(844 Views)

No, you are right, you can't assume it. 

It is much more standard/common usage in C, but you can't assume it.

 

0 Kudos
Message 16 of 16
(830 Views)