Variant assignment in LotusScript errors if deep copy is required

  • Variants can contain arrays and lists.- Arrays and lists can contain Variants.

  • A Variant containing a list or an array can be assigned to another Variant.

  • A Variant can contain a list of arrays.

  • But you can’t assign a Variant containing a list of arrays to another Variant!!!

So the following code is ok, all except the very last line! “b = a”

Sub debugColl(coll As Variant)

ForAll refVar In coll

Print DataType(refVar)

End ForAll

End Sub

Sub Initialize()

Dim l List As Variant

Dim a As Variant

Dim b As Variant

a = Split({a,b,c}, {,})

b = a

debugColl b

a = l

a({one}) = 1

a({two}) = {deux}

b = a

debugColl b

a({split}) = Split({a,b,c}, {,})

debugColl a

b = a

End Sub

You can pass a list of arrays by reference but you can’t assign it to another Variant!!!

Variant assignment in LotusScript performs a shallow copy (not a deep copy) and errors if it detects a deep copy is required.

arrrrgggg!!