Operator - Foundation

Minus operator (unary): reverses sign of operand (multiplies operand by -1). Minus operator (binary): numeric subtraction or string concatenation.

Syntax
<nValue1>  - <nValue2>   // subtraction
<dDate1>   - <dDate2>    // subtraction
<dDate>    - <nValue>    // subtraction
<cString1> - <cString2>  // string concatenation
Parameters
<nValue1>
<nValue1> and <nValue2> are numeric expressions. The value of <nValue2> is subtracted from the value <nValue1>.
<dDate1>
<dDate1> and <dDate2> are expressions of the data type date. The value of <dDate2> is subtracted from the value <dDate1>. The result is numeric and indicates the difference in days.
<dDate>
<dDate> is an expression with data type date from which the number of days <nValue> is to be subtracted.
<cString1>
<cString1> and <cString2> are character expressions. The value of <cString2> is concatenated (attached) to the end of <cString1>after all blank spaces (Chr(32)) at the end of <cString1> have been removed.
Description

The operations of the subtraction operator are dependent on the program context and on the data type of the operands:

When a unary subtraction operator precedes a numeric expression, it corresponds to a multiplication with the value -1. This changes the sign of the numeric value. This operation has precedence over all other numeric operations.

When the binary subtraction operator is used with two numeric expressions <nValue1> and <nValue2>, it subtracts the value of the right expression <nValue2> from the value of the left expression <nValue1>. The result of the subtraction is a numeric value which is the difference between the two expressions.

When the subtraction operator is used with two date expressions <dDate1> and <dDate2>, it subtracts the date of the right expression <dDate2> from the date of the left expression <dDate1>. The result of the subtraction is a numeric value which indicates the difference in number of days.

If the left operand of the subtraction operator is a date expression <dDate> and the right operand is a numeric expression <nValue>, the numeric number of days <nValue> is subtracted from the date <dDate>. The result is a date value. A runtime error is generated if the left operand is numeric and the right operand is of data type date.

When the binary subtraction operator is used with two character expressions <cString1> and <cString2>, the character string of the right expression is attached to the left expression <cString1>, after all blank spaces (Chr(32)) at the end of the left character expression are removed and placed at the end of the resulting character string.

Examples
The subtraction operator (-)
// This example shows various results of the subtraction operator. 

PROCEDURE Main 
   LOCAL nValue := 10 

   ? -nValue                        // result: -10 
   ? nValue := -nValue              // result: -10 
   ? nValue := -nValue              // result: 10 

   ?  4 - 4                         // result: 0 
   ? - 4 - 4                        // result: -8 

   ? CtoD("12/31/94") - 7           // result: 12/24/94 

   ? CtoD("12/31/94") - ; 
     CtoD("12/31/93")               // result: 365 

   ? "James " - "Bond"              // result: JamesBond 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.