Multiple 2D arrays types in one Extension Command

Questions and coding techniques, including USB cameras and devices.
Post Reply
admin
Site Admin
Posts: 33
Joined: Tue Jan 14, 2014 12:39 pm

Multiple 2D arrays types in one Extension Command

Post by admin » Mon Oct 07, 2019 1:41 pm

When developing an Extension Command library, you may want to use different array data types with similar args lists. There's two ways to handle this:
  • Define a set of commands each with the desired array data type.
  • Create one extension command which accepts any of the data types.
For example, using the "abc..." in previous postings, if we have two sensor types that generate float and string data respectively, the command declaration might be

lpCmd[nCommands++] = (LPSTR)"\",\"abcGetSensorData\", Res, P_VARIANT_ARRAY,
P_SQ_BRACKET_LEFT, P_NUMBER, P_NUMBER, P_SQ_BRACKET_RIGHT, P_NUM_VARIABLE)";


The declaration is the same for arrays, so the command code's first operation is to identify the array data type.

Array2(SensorID_Values&[20,20], ElementCount) // declare the float array
Array2(SensorID_Data$[20,20], ElementCount) // declare the string array

In the arg pointer list, these are
anArgBuffer[0] == SensorID_Values& array pointer
anArgBuffer[1,2] == array start row and column indices
anArgBuffer[3] == return variable (Result)

or
anArgBuffer[0,1] == SensorID_Data$ array pointer
anArgBuffer[2,3] == array start row and column indices
anArgBuffer[4] == return variable (Result)

To identify the data type, get an array pointer from anArgBuffer[0]. If this is a float type, the array type will be valid (Float32Var == 5). If not, then test for the string array type.

In the body of the command code, process each data type accordingly.

If you have more questions, contact Tech Support. We can provide a sample DLL source project for Visual Studio 2017 and later.
Stewart (Admin) @ pixcl

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests