>  Docs Center  >  Libraries  >  ASTROLIB  >  COMPARE_STRUCT
Libraries

COMPARE_STRUCT

COMPARE_STRUCT

Name


      COMPARE_STRUCT

Purpose


      Compare all matching tag names and return differences

Explanation


      Compare all matching Tags names (except for "except_Tags")
      between two structure arrays (may have different struct.definitions),
      and return a structured List of fields found different.
      The Exelis contrib library has a faster but less powerful procedure
      struct_equal.pro, see
      http://www.exelisvis.com/Default.aspx?tabid=1540&id=1175

Calling Sequence


      diff_List = compare_struct( struct_A, struct_B [ EXCEPT=, /BRIEF,
                                    /FULL, /NaN, /RECUR_A, /RECUR_B )

Inputs


      struct_A, struct_B : the two structure arrays to compare.
      Struct_Name : for internal recursion use only.

Optional Input Keywords


              EXCEPT = string array of Tag names to ignore (NOT to compare).
              /BRIEF = number of differences found for each matching field
                                              of two structures is printed.
              /FULL = option to print even if zero differences found.
              /NaN = if set, then tag values are considered equal if they
                      are both set to NaN
              /RECUR_A = option to search for Tag names
                              in sub-structures of struct_A,
                              and then call compare_struct recursively
                              for those nested sub-structures.
              /RECUR_B = search for sub-structures of struct_B,
                              and then call compare_struct recursively
                              for those nested sub-structures.

Note


              compare_struct is automatically called recursively
              for those nested sub-structures in both struct_A and struct_B
              (otherwise cannot take difference)

Output


      Returns a structure array describing differences found.
      which can be examined using print,diff_List or help,/st,diff_List.
      The tags are
      TAG_NUM_A - the tag number in structure A
      TAG_NUM_B - the tag number in structure B
      FIELD - the tag name
      NDIFF - number of differences (always 1 for a scalar tag).

Procedure


      Match Tag names and then use where function on tags.

Example


      Find the tags in the !X system variable which are changed after a
      simple plot.
      IDL> x = !X ;Save original values
      IDL> plot, indgen(25) ;Make a simple plot
      IDL> help,/str,compare_struct(x,!X) ;See how structure has changed
            and one will see that the tags !X.crange and !X.S are changed
            by the plot.

Modification History


      written 1990 Frank Varosi STX @ NASA/GSFC (using copy_struct)
      modif Aug.90 by F.V. to check and compare same # of elements only.
      Added /NaN keyword W. Landsman March 2004
      Don't test string for NaN values W. Landsman March 2008



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
   Contact Us