03-27-2007 10:32 AM
03-27-2007 11:30 PM
Hi Bob,
If I remember correctly, the first byte of a Pascal "string" is the string's character-length. I'd define this CLF parameter as an array of bytes(U8). Convert the input string to an array of U8 and concatinate the array-length as the first byte (obviously you don't want to try to pass strings larger than 255 characters!) It's been a long time since I programmed in Pascal (~1988) and I'm only fairly confident this advice is right.
Cheers!
03-28-2007 07:10 AM
03-28-2007 10:27 AM
Thanks for the replies.
I've selected the "Pascal String Pointer" in the configuration of Call Library Function node. I tried the "pascal.vi", it seems that the U8 array output is not compatible with the CLF node input(shown as String type). I also tried to add a U8 to String converter in the pascal.vi. The error code shown up is still #1097. Looks like the string has not been successfully transfered into the DLL node. Any other solutions? thanks....
Best regards,
Bob Wu
03-28-2007 02:12 PM
That's two, Wiebe!
Bob, Wiebe's right, the "Pascal String Pointer" is the way to go. It will allow you to pass-in the string directly - no worries about concatinating the length-byte - LabVIEW will take care of that.
As for error 1097, what "Calling Convention" are you using? Is the DLL supposed to return any data? The prototype you posted is kinda confusing (those smiley-faces have a mind of their own.) What, exactly, are the data-types being passed?
Cheers!
03-28-2007 09:45 PM
@tbd wrote:... What, exactly, are the data-types being passed?
03-28-2007 09:52 PM
03-28-2007 10:15 PM - edited 03-28-2007 10:15 PM
Message Edited by tbd on 03-28-2007 10:19 PM
03-31-2007 10:17 PM
Thanks, even pre-allocated space for the return value, the error still happened. I'm wondering if there is any problem within the DLL itsself.
Bob Wu
03-31-2007 11:50 PM
Hi Bob,
Forgive me! - I've been assuming we were trying to use a working DLL - is this a DLL you're developing? It seems from reading here, here, and here, that pchars need to be paired with a length-parameter. They also said that return-values are allocated by the DLL (Delphi) and may be "freed" by delphi - invalidating the reference in the caller.
Not sure what it takes to get a Delphi compiler environment going. I'd try building a DLL with a U32 return_type. Once that's working, add a pchar parameter w/length parameter passed by value, and modify the pchar inside the DLL. Once that's working, you're home free.
Cheers!