11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Description$LISTSAME compares the contents of two lists and returns 1 if the lists are identical. If thelists are not identical, $LISTSAME returns 0.A valid list can either be a list created using $LISTBUILD, or a null string (""). If list is nota valid list, you receive a error.ExamplesThe following example returns 1, because the two lists are identical:SET x = $LISTBUILD("Red","Blue","Green")SET y = $LISTBUILD("Red","Blue","Green")WRITE $LISTSAME(x,y)The following example returns 0, because the two lists are not identical:SET x = $LISTBUILD("Red","Blue","Yellow")SET y = $LISTBUILD("Red","Blue","Green")WRITE $LISTSAME(x,y)NotesIdentical Lists$LISTSAME considers two lists to be identical if the string representations of the two listsare identical. This is not the same equivalence test as the one used by other list operations,which test using the internal representation of a list. This distinction is easily seen whencomparing a number and a numeric string, as in the following example:SET x = $LISTBUILD("365")SET y = $LISTBUILD(365)IF x'=y { WRITE !,"number and numeric string lists differ" }WRITE !,$LISTSAME(x,y)," number and numeric string lists identical"The IF comparison tests the internal representations of these lists (which are not identical).$LISTSAME performs a string conversion on both lists, compares them, and finds themidentical.The following example shows two lists with various representations of numeric elements.$LISTSAME considers these two lists to be identical:SET x = $LISTBUILD("360","361","362","363","364","365","366")SET y = $LISTBUILD(00360.000,(19*19),+"362",363,364.0,+365,"3"_"66")WRITE !,$LISTSAME(x,y)," lists are identical"$LISTSAMEIn the following example, both $LISTSAME comparisons returns 0, because these lists arenot considered identical:<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 259

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!