User Guide

DLL Component
Ints
Say we have a DLL component where input 'x' has been defined as an Int connector. The pIn array is already defined as an array of ints so
to get at this value in C all we only need do the following:
int value = pIn[x];
If we then wanted to set the corresponding output value we'd do this:
pOut[x] = value;
Floats
For the Float type we need to cast to a C float like this:
float value = *((float*)&pIn[x]);
Note that we can't just cast the value of pIn[x] to a float as this would convert from an int to a float. The 4 bytes that make up the int value
need to be addressed as if they were 4 bytes making up a float. Hence we need to cast the address of the value to a float pointer and then
dereference that.
To set the corresponding output we need to do the same cast for the pOut array:
*((float*)&pOut[x]) = value;
Booleans
Boolean types become a C bool type. A bool in C is a single byte. We therefore cast as follows:
bool value = *((bool*)&pIn[x]);
To set the corresponding output we need to do the same cast for the pOut array:
*((bool*)&pOut[x]) = value;
Strings
From the table you'll see that FlowBotics Studio Strings are represented as a zero terminated array of chars. In this case we need to cast as
follows:
char* value = *((char**)&pIn[x]);
Up to now we've dealt with data whose value is contained within the 4 bytes that defined the array element. However, for strings the value is
a pointer to other data i.e. an array of chars.
So when it comes to sending a string to the output array we need to create our own array of chars. The memory management we leave up to
you.
This time, to set the corresponding output we need to do more than assign a value. Something like the following would be typical for strings:
// Delete previous string and reset pOut entry
if( pOut[x] )
188 of 212