KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Retrieving the type of 2D array
PRODUCT: 4D | VERSION: 6.7.5 | PLATFORM: Mac & Win
Published On: January 11, 2002

Currently the 4D 6.7.x API does not support 2-Dimensional Arrays. In the near future this will no longer be the case, but if a developer would like to return the type of a 2D array there is currently not an API function that will retrieve this information. Thibaud Arguillere has written a wrapper that will return the type of a 2-D array by determining the value of the Zero element of the array. In 4D all arrays contain a zero element so by checking this value a developer can check the type of array.

PA_VariableKind wrapPA_Get2DArrayKind(PA_Variable array2D);

PA_VariableKind wrapPA_Get2DArrayKind(PA_Variable array2D)
{
PA_VariableKind kind = eVK_Undefined;
PA_Handle dataOfArray2D; // for code readibility

if(PA_GetVariableKind(array2D) == eVK_ArrayOfArray)
{
dataOfArray2D = array2D.uValue.fArray.fData;
if(dataOfArray2D)
{
kind = (PA_VariableKind) ((PA_Variable *)
*dataOfArray2D)->fType; // this is element 0. There is always an
element
}
}

return kind;

} /* wrapPA_Get2DArrayType */

In the core of our plug-in we would call the Wrapper function like so:

// ...code...
PA_Variable v;
PA_VariableKind kindOfArray;

v = PA_GetVariableParameter(params, 1);

kindOfArray = wrapPA_Get2DArrayKind(v); // make a call to the wrapper
// ...code...

Using this wrapper function in your plug-in code you can return the type of a 2-D array. In 4D you would simply pass an array (PA_Variable) to the plug-in.