Skip to content

MvREFERENCEARRAY#


Creates a reference from one array to another, such that changes to one will appear to be made to the other

Syntax
<MvREFERENCEARRAY NAME = "string: {  expression } | literal" 
    VARIABLE = "string: {  expression } | literal">
    <MvDIMENSION INDEX = "numberic: { expression } | literal">
    <MvMEMBER NAME= "string: {  expression } | literal"> 
</MvREFERENCEARRAY>

Attributes#

Attribute Description
NAME Required. Source Variable Name
VARIABLE Required. Target Variable Name or an expression that results in a variable name

Note

<MvDIMENSION> and <MvMEMBER> refer to the VARIABLE parameter, NOT the NAME parameter.

Examples#

In its simplest form one array can be directly referenced by another name. This example makes a local array available globally.

<MvREFERENCEARRAY NAME = "g.global_array" VARIABLE = "l.local_array"></MvREFERENCEARRAY>

In typical usage a sub member of a structure or array can be referenced, simplifying programming syntax.

For this example assume an array of data like this:

l.products[1]:id = 27
l.products[1]:code = "polol042"
l.products[1]:name = "Polo Shirt"
A string expression creates a reference to a products array record assigned to prod.

<MvASSIGN NAME="l.posn" VALUE="{ 1 }">
<MvREFERENCEARRAY NAME = "l.prod" VARIABLE = "l.products">
    <MvDIMENSION INDEX = "{ l.posn }">
</MvREFERENCEARRAY>

The variable l.prod now contains a reference to the array index such that l.prod:code is the same as l.products[1]:code. Using this in a loop results in clearer code.

<MvASSIGN NAME = "l.posn" VALUE = 1>
<MvASSIGN NAME = "l.last" VALUE = "{ miva_array_max(l.products)}">

<MvWHILE EXPR = "{ l.posn LE l.last }">
    <MvREFERENCEARRAY NAME = "l.prod" VARIABLE = "l.products">
        <MvDIMENSION INDEX = "{ l.posn }">
    </MvREFERENCEARRAY>

    ID: <MvEVAL EXPR = "{ l.prod:id }"><br>
    Code: <MvEVAL EXPR = "{ l.prod:code }"><br>
    Name : <MvEVAL EXPR = "{ l.prod:name }"><br>

    <MvASSIGN NAME = "l.posn" VALUE = "{ l.posn + 1 }">
</MvWHILE>