Skip to content

Struct Variable Assignments

A variable of a particular struct type can be copied to another variable of the same struct type.

tUSAddress myShippingAddress
tUSAddress myBillingAddress
...
Move myShippingAddress to myBillingAddress

The above code copies the variable myShippingAddress to the myBillingAddress variable using a deep memberwise copy operation. Each member of the struct type is copied from the myShippingAddress variable to the myBillingAddress variable. The above code is functionally equivalent to the following:

Move myShippingAddress.sStreet  to myBillingAddress.sStreet
Move myShippingAddress.sCity    to myBillingAddress.sCity
Move myShippingAddress.sState   to myBillingAddress.sState
Move myShippingAddress.iZipCode to myBillingAddress.iZipCode

Struct variable assignments of different struct types, as well as struct variable assignments to/from a non-struct type, are illegal and will result in a run-time error.