# Operators

> Source: https://manual.pvxplus.com/appendix/operators

The information below describes the traditional operators (e.g. + - \* /) you can use in PxPlus, along with other operators for which support has been added in recent versions (e.g. the auto-increment and decrement operators, assignment operators, the **[LIKE Operator](https://manual.pvxplus.com/appendix/operators#Mark6)**, and the **[Apostrophe Operator](https://manual.pvxplus.com/appendix/apostrophe-operator)**).

See **[Numeric Values](https://manual.pvxplus.com/pxplus-user-guide/language-elements/data-types-literals-and-variables/numeric-values)** and **[String Values](https://manual.pvxplus.com/pxplus-user-guide/language-elements/data-types-literals-and-variables/string-values)** for additional information on the use of some of these operators.

## Arithmetic Operators

The following operators are used to perform calculations:

|  |  |  |
| --- | --- | --- |
|  | **+** | *Where:* A + B ***adds*** A to B |
|  | **-** | *Where:* A - B ***subtracts*** B from A |
|  | **\*** | *Where:* A \* B ***multiplies*** A by B |
|  | **/** | *Where:* A / B ***divides*** A by B |
|  | **^** | *Where:* A ^ B raises A to the ***power*** of B (\*\* is equivalent to ^) |
|  | **\|** | *Where:* A \| B divides A's ***remainder*** by B |

## Assignment Operators

The following assignment operators are included in the general syntax of the language:

| **Operator** | **Meaning** | **Description** |
| --- | --- | --- |
| **+=** | **Add To** | Can be used with numerics or strings.<br>***Example:***<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Numeric:* \| A+=1 is the same as A=A+1 \|<br>\| *String:* \| A$+="G" is the same as A$=A$+"G" \| |
| **-=** | **Subtract From** | Not valid for strings.<br>***Example:***<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Numeric Only:* \| B-=A+1 is the same as B=B-(A+1) \| |
| **\*=** | **Multiply By** | Can be used with numerics or strings.<br>***Example:***<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Numeric:* \| B\*=A+1 is the same as B=B\*(A+1) \|<br>\| *String:* \| A$\*=5 is the same as A$=A$+A$+A$+A$+A$ \| |
| **/=** | **Divide By** | Not valid with strings.<br>***Example:***<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Numeric Only:* \| B/=A+1 is the same as B=B/(A+1) \| |
| **^=** | **Exponentiation** | Raise to. Not valid with strings.<br>***Example:***<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Numeric Only:* \| B^=A is the same as B=B^A \| |
| **\|=** | **Modulus/Remainder from Division** | Not valid with strings.<br>***Example:***<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Numeric Only:* \| B\\|=A is the same as B=MOD(B,A) \| |

## Auto

**Increment and Decrement**  
  
In addition to the assignment operators, there are ***increment*** and ***decrement*** features:

|  |  |  |
| --- | --- | --- |
|  | **++** | Auto-increment (pre-increment when prefixed to variable name, post-increment if suffixed); e.g. ++variable ***or*** variable++. |
|  | **--** | Auto-decrement (pre-decrement when prefixed to variable name, post-decrement if suffixed); e.g.--variable ***or*** variable--. |

Note:  
If an error occurs during execution of your directive, no increment or decrement takes place. (This is true for both pre- and post-operations.)  
  
With *pre*-increment or decrement, the value returned is the value of the variable after the increment or decrement.  
  
With *post*-increment or decrement, the value returned is the value of the variable before the increment or decrement. After your directive is executed, your variable is incremented or decremented by 1.

***Example:***

```
A=0, Y$=""
READ (1,IND=A++,ERR=*NEXT)X$; Y$+=X$; GOTO *SAME

or

Y$+=RCD(1,IND=A++,ERR=*NEXT); GOTO *SAME
```

See **[Labels/Logical Statement References](https://manual.pvxplus.com/appendix/labels-logical-statement-references)**.

## LIKE Operator

Use the **LIKE** operator for string comparisons. The PxPlus default (with the **['TL'](https://manual.pvxplus.com/parameters/tl)** system parameter set to ***Off***) is to take the string expression on the left and compare it to the string mask on the right. In the default mode, you can apply all the regular expression rules of the **[MSK( )](https://manual.pvxplus.com/functions/msk)** function to using the **LIKE** operator. Use the following format:

```
IF A$ LIKE "ABC" THEN ...
```

To make your conversions from Thoroughbred® easier, set **'TL'** to ***On***. With this parameter ***On***, the **LIKE** operator emulates the Thoroughbred® matching of patterns.

See **[SET_PARAM](https://manual.pvxplus.com/directives/set-param)** directive, **[MSK( )](https://manual.pvxplus.com/functions/msk)** function and **['TL'](https://manual.pvxplus.com/parameters/tl)** system parameter.

## Apostrophe Operator

The apostrophe operator is used to assign, retrieve, list, and make dynamic changes to a given control or object's properties.

For the syntax and use of the apostrophe, see **[Apostrophe Operator](https://manual.pvxplus.com/appendix/apostrophe-operator)**.

Thoroughbred® is a registered trademark of Thoroughbred Software International Inc.
