AnsweredAssumed Answered

vrf Importing DLL's, passing by reference

Question asked by VRFuser on Aug 19, 2004
Shawn Fessenden wrote the following:

>>int __stdcall C843_qVST(int iId, char* *szAxes, char* *names, int maxlen);
(Slight correction, char * szAxes, not *szAxes, but *names is correct)
> Oh my! Watch that. Are you *sure* it's "char* *szAxes" etc? I'm sure it's
> likely... as the names imply plural. That's a string array.

Pretty sure.  Although I thought char* described a string scalar, not a string
array.

>>1.  How do I create that in VEE?
>
> Check the documentation for C834_qVST and see how exactly these arrays are
> supposed to be terminated. I'm assuming that "maxlen" means "maximum number
> of strings passed in array", not "maximum *length* of buffers supplied in
> string array". The meaning of maxlen is crucial. Unfortunately it's
> ambiguous.

From the manual:
iId: Id of controller
szAxes: identifier of the stages, if "" or NULL all axes are affected
names: buffer for storing the string read in from controller, lines are
separated by
(line feed)
maxlen: size of name, must be given to avoid buffer overflow
Returns TRUE if successful, FALSE otherwise

The sample program (in C) has:
char stages[1024];
int ID;
ID = 1;
C843_qCST(ID, "1234", stages, 1023);
printf("qCST() returned "%s"", stages);
//The output should be "1=NOSTAGE
2=NOSTAGE
3=NOSTAGE
4=NOSTAGE
"

> That is, what you're passing is a pointer to a pointer list for both Text
> arrays. There must be some way for the compiled function to determine when
> it has reached the end of each list. Often the end marker is a NULL pointer,
> and you'll have to use some spiffy spoofing to accomplish that.
>
> If "maxlen" means "maximum length of buffers for strings", then this is a
> retrieval call (not a "set" call) and you can use something like "Axes[i] =
> "*" * maxlen;" to allocate a buffer for each Axis and name.

I've already got a string length 1024 (filled with " ") and fed it to the
function, but it just regurgitates it and returns a 0, i.e. unsuccessful.

Any advice appreciated!

--
Graeme Hilton
Product Engineer

Schlumberger Sensa

---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

Outcomes