# compare statement

The `compare` statement compares two dynamic
arrays.

## Syntax

```
compare str.exp1 to str.exp2{present var1} {missing var2}
```

## Parameter(s)

| str.exp1 | String whose elements are to be compared with str.exp2. |
| --- | --- |
| str.exp2 | String whose elements are to be compared with str.exp1. |
| present var1 | At completion, contains a list of elements that exist in str.exp1 and in str.exp2. |
| missing var2 | At completion, contains a list of elements that exist in str.exp1 but do not exist in str.exp2. |

## Description

The compare statement scans through each element in *str.exp1* to verify if that element also exists in *str.exp2*. At completion, *var1* contains a list of elements
that exist in *str.exp1* and in *str.exp2*. At completion, *var2* contains a list of elements
that exist in *str.exp1* but do not exist in *str.exp2*.

## Example(s)

```
str1 = "a":@vm:"b":@vm:"c"
str2 = "a":@vm:"d":@vm:"e"
*
compare str1 to str2 present x missing y
print "Result of x = ":x
print "Result of y = ":y
```
This outputs the following:

```
Result of x = a
Result of y = b]c
```

## See also

- [$options directive](https://d3codex.com/pickbasic-flashbasic/dollar-options-directive/)

---
Source: https://d3codex.com/pickbasic-flashbasic/compare-statement/ - part of the D3Codex reference.
