version 2003
PA_GetVariableParameter (params; index) PA_Variable
| Parameter | Type | Description | |
| params | PA_PluginParameter | Parameters received in PluginMain | |
| index | short | Index of the parameter in params | |
| Function result | PA_Variable | Value (of type PA_Variable) of the index parameter |
Description
The routine PA_GetVariableParameter returns the PA_Variable that is pointed to by the index parameter in params.
Refer to PA_Variable and PA_Array to see how those structures are declared.
See Create a new plugin for a description of parameter accessors.
NOTE: The first parameter starts at index 1
Example
Sum a Long integer array. Returns -1 if the array is not of this type.
// Somewhere:
double SumArrayLong(PA_Variable array);
void PluginMain( long selector, PA_PluginParameter params)
{
switch ( selector )
{
. . .kInitPlugin, kDeinitPlugin ...
case kMyRoutine : // declared in STR# as SumLongArray(&Y):8
{
PA_Variable array;
array = PA_GetVariableParameter(params, 1);
SumArrayLong(array);
}
break;
}
}
double SumArrayLong(PA_Variable array)
{
double result;
register long i;
// First, check if we have an array of type long
if (array.fType != eArrayLongint)
result = -1.0;
else
{
// Then, sum the array.
// As we have already checked the type of the PA_Variable, we know
// that PA_GetArrayNbElements and PA_GetLongintInArray will be ok.
result = 0.0;
for(i = 1; i <= PA_GetArrayNbElements(array); i++)
result = result + PA_GetLongintInArray(array, i);
}
PA_ReturnDouble(params, result);
}
See Also
Create a new plugin, PA_Variable.
Error Handling
PA_GetLastError keeps the last error that occurred before calling the routine.