DataBasic Reference > Statements and Intrinsic Functions > C > COMPARE Statement

Comment on this topic

Documentation Comments

Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.

Reality V15.0 ()

COMPARE Statement (DataBasic) (m618703+compare_s.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

COMPARE Statement

Compares the elements in two dynamic arrays.

Syntax

COMPARE dynArray1 TO dynArray2{ PRESENT varFound}{ MISSING varMissing}{, caseMode}

Syntax Elements

dynArray1, dynArray2
The dynamic array expressions to be compared.

varFound A variable in which to return the elements from dynArray1 that were found in dynArray2.

varMissing A variable in which to return the elements from dynArray1 that were not found in dynArray2.

caseMode A string expression containing one of the following:

"S" or "s" Specifies that case is significant when comparing elements.

"I" or "i" Specifies that case should be ignored when comparing elements.

If caseMode is not specified, the current data case setting is used. See Case Sensitivity for more details.

If an invalid string is specified, a run-time error occurs.

Comments

The COMPARE statement compares each element (attribute, value and subvalue) in dynArray1 with the elements in dynArray2. Those for which matching elements are found are copied into varFound, while those that are not found are copied into varMissing. Each element in varFound and varMissing is terminated with the same system delimiter as in dynArray1.

Example

ARY1 = "X":@AM:"Y":@AM:"Z"
ARY2 = "A":@AM:"X":@AM:"B"
COMPARE ARY1 TO ARY2 PRESENT P MISSING M
PRINT "Found = ":M
PRINT "Not found = ":P

This outputs the following:

Found = X
Not found = Y^Z

RealityV15.0Comment on this topic