Share this page

# lrc_variant_<Type-Name>Array_by_ref

Other deprecated syntax variations of this function are currently supported for backwards compatibility:

## lrc_Put<Type-Name>ArrayByRefInVariant

## lrc_variant<Type-Name>ArrayByRef

## lrc_Put<Type-Name>Array_by_refInVariant

Assignment to Variants - By Reference and By Variant

Returns a reference to an array of Type-Name in a variant.

## Return Values

lrc Return Values

## Parameterization

You cannot use standard parameterization for any arguments in this function.

VARIANT lrc_variant_<Type-Name>Array_by_ref( <Type-Name>Array array );

Array | An array of the specified type.

The lrc_variant_<Type-Name>Array_by_ref family of functions returns a reference to an array of the type given in Type-Name. The return type is a variant.

The calls include:

VARIANT lrc_variant_BoolArray_by_ref(BoolArrayarray);

VARIANT lrc_variant_BstrArray_by_ref(BstrArray array);

VARIANT lrc_variant_ByteArray_by_ref(ByteArray array);

VARIANTlrc_variant_CharArray_by_ref(CharArray array);

VARIANT lrc_variant_CoObjectArray_by_ref(CoObjectArray array);

VARIANT lrc_variant_CurrencyArray_by_ref(CurrencyArray array);

VARIANT lrc_variant_DateArray_by_ref(DateArray array);

VARIANT lrc_variant_DispObjectArray_by_ref(DispObjectArray array);

VARIANT lrc_variant_DoubleArray_by_ref(DoubleArray array);

VARIANT lrc_variant_ErrorArray_by_ref(ErrorArray array);

VARIANT lrc_variant_FloatArray_by_ref(FloatArray array);

VARIANTlrc_variant_IntArray_by_ref(IntArray array);

VARIANT lrc_variant_LongArray_by_ref(LongArray array);

VARIANT lrc_variant_ShortArray_by_ref(ShortArray array);

VARIANTlrc_variant_UintArray_by_ref(UintArray array);

VARIANT lrc_variant_UlongArray_by_ref(UlongArray array);

VARIANT lrc_variant_UshortArray_by_ref(UshortArray array);

VARIANT lrc_variant_VariantArray_by_ref(VariantArray array);

## Example

This example demonstrates that the lrc_*_ByRef class of functions deals with references to the underlying data, and not the data itself.

    VARIANT vRef, vRef1;
    FloatArray array0, array1, array2;
    float fValue;

    // Create and populate an array
    array0 = Create1DFloatArray(0, 5);
    PutElementIn1DFloatArray(array0, 0, lrc_float("1.1"));
    PutElementIn1DFloatArray(array0, 1, lrc_float("20.02"));
    PutElementIn1DFloatArray(array0, 2, lrc_float("300.003"));
    PutElementIn1DFloatArray(array0, 3, lrc_float("4000"));
    PutElementIn1DFloatArray(array0, 4, lrc_float("50000"));

    // Get an element from the array and display it
    fValue = GetElementFrom1DFloatArray(array0,1);
    lr_output_message("Second element in array0 = %f", fValue);

    Example: Output:
    Action.c(20): Second element in array0 = 20.020000

    // Get references to the array with two possible syntaxes
    vRef = lrc_variant_FloatArray_by_ref(array0);
    vRef1 = lrc_PutFloatArrayByRefInVariant(array0);

    //Convert the reference to a float array
    array1= lrc_GetFloatArrayFromVariant(&vRef);

    // Get an element from the new array and display it
    fValue = GetElementFrom1DFloatArray(array1,1);
    lr_output_message("Second element in array1 = %f", fValue);

    Example: Output:
    Action.c(30): Second element in array1 = 20.020000

    //Change an element in the original array
    PutElementIn1DFloatArray(array0, 1, lrc_float("101.99"));

    // Get an element from the original array and display it
    fValue = GetElementFrom1DFloatArray(array0,1);
    lr_output_message("Second element in array0 after change = %f", fValue);

    Example: Output:
    Action.c(38): Second element in array0 after change = 101.989998

    // Get an element from the new array and display it. It's the same array
    fValue = GetElementFrom1DFloatArray(array1,1);
    lr_output_message("Second element in array1 after change to array0 = %f", fValue);

    Example: Output:
    Action.c(43): Second element in array1 after change to array0 = 101.989998

    /* Confirm that what we've been passing is references to the same array
    by showing that the addresses are the same.*/
    if (array0 == array1) lr_output_message("There is only one array");

    Example: Output:
    Action.c(46): There is only one array

    // Used different syntax above to get the reference, but still the same array.
    array2= lrc_GetFloatArrayFromVariant(&vRef1);
    fValue = GetElementFrom1DFloatArray(array2,1);
    lr_output_message("Second element in array2 after change to array0 = %f", fValue);

    Example: Output: Action.c(53): Second element in array2 after change to array0 = 101.989998

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: