Operators

User Annotations: operators
Chris Cookson : chris d0t cookson at, createit d0t co d0t nz
09/07/2011 06:46 a.m.
BITXOR is a useful operator if you want to generate alternating true/false values.
If the value is undefined or zero, the following example will return 1 otherwise it will return one.
A practical use would be to apply alternating row colours using an array of two elements with either a CSS class name or hex colour value.
Since Mivascript arrays are 1 based, it is necessary to add one to the result of the BITXOR to get the array index.
<mvassign name = "l.rowclass" value = "{miva_array_deserialize('row1,row2'}">
<mvfor count = "{ 10 }">
<mvassign name = "l.alternate" value = "{l.alternate BITXOR 1}">
<tr class = "{l.rowclass[l.alternate + 1]}"><td>Some text</td></tr>
</mvfor>