Knowledge Base Article # Q200172

Summary

This article demonstrates a simple procedure for comparing struct fields.

Programming languages typically do not support structure comparison directly. In ATEasy, structures can be compared by converting them to a Variant and then comparing the variants. In ATEasy, when a structure is assigned to a variant, the structure is converted to an array of variant data types, where each field of the structure becomes an element in the array.

A generic structure comparison procedure can be coded as follows:

Procedure CompareStructs(vrStruct1, vrStruct2): Bool! Compare structs of the same type, return TRUE if equal, FALSE otherwise--------------------------------------------------------------------------------vrStruct1: Val VariantvrStruct2: Val Varianti: Long{! Must have the same number of fieldsIf VarDimSize(vrStruct1, 0)<> VarDimSize(vrStruct2, 0) Then Return FALSE