Difference between revisions of "Recital Operators"

From Recital Documentation Wiki
Jump to: navigation, search
Line 16: Line 16:
 
===Arithmetic Operators===
 
===Arithmetic Operators===
 
Recital supports the use of the following Arithmetic Operators:
 
Recital supports the use of the following Arithmetic Operators:
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 36: Line 35:
 
|-
 
|-
 
|}
 
|}
 
  
 
When dealing with Date data types, the operators work as follows:  
 
When dealing with Date data types, the operators work as follows:  
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 49: Line 46:
 
|-
 
|-
 
|}
 
|}
 
  
 
'''Example'''
 
'''Example'''
Line 60: Line 56:
 
         30
 
         30
 
</code>
 
</code>
 
  
 
===Comparison Operators===
 
===Comparison Operators===
 
The following Comparison Operators are supported in Recital:
 
The following Comparison Operators are supported in Recital:
 
 
   
 
   
 
{| class="wikitable"
 
{| class="wikitable"
Line 88: Line 82:
 
|-
 
|-
 
|}
 
|}
 
  
 
The Comparison Operators are always evaluated from left to right.
 
The Comparison Operators are always evaluated from left to right.
  
 
===Increment and Decrement Operators===
 
===Increment and Decrement Operators===
 +
The ++ operator is used to automatically increment a previously declared numeric memory variable by one.  The ++ operator must be placed at the beginning of the command line.
 +
 +
'''Example'''
 +
<code lang="recital">
 +
i=0
 +
do while i <100
 +
    ++ i
 +
enddo
 +
</code>
 +
 +
The -- operator is used to automatically decrement a previously declared numeric memory variable by one.  The -- operator must be placed at the beginning of the command line.
 +
 +
 +
==Example==
 +
<code lang="recital">
 +
i=100
 +
do while i > 0
 +
    --i
 +
enddo
 +
</code>
 +
 
===String Concatenation Operator===
 
===String Concatenation Operator===
 
When dealing with string data types, the + and - operators perform the following concatenation operations:  
 
When dealing with string data types, the + and - operators perform the following concatenation operations:  
Line 115: Line 129:
 
===String Search Operators===
 
===String Search Operators===
 
The following String Search Operators are supported in Recital:
 
The following String Search Operators are supported in Recital:
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 125: Line 138:
 
|-
 
|-
 
|}
 
|}
 
  
 
===String Substitution Operator===
 
===String Substitution Operator===

Revision as of 13:30, 6 November 2009

Recital Operators

Assignment Operators

Values are assigned to memory variables using the the equals = operator or the inline assignment := operator.

cVAR1 = 'newer value'
cVAR1 := 'newest value'

Note that the store command can also be used to assign valuesand can operate on more than one memory variable in a single command.

store 'new value' to cVAR1, cVAR2

Arithmetic Operators

Recital supports the use of the following Arithmetic Operators:

Operator Operation Precedence
() Parentheses 1
** Exponentiation 2
* Multiplication 3
/ Division 3
% Modulus/Remainder 3
+ Addition 4
- Subtraction 4

When dealing with Date data types, the operators work as follows:

Operator Operation
+ <expD> + <expN> returns a date plus the number of days specified in <expN>.
- Returns the interval between the two dates as a number of days.

Example

? 2*3^2
        18
? 2*25%7
      1.00
? date() + 30 - date()
        30

Comparison Operators

The following Comparison Operators are supported in Recital:

Operator Operation
= Equal To
== Exactly Equal To / Matches Pattern
<> Not Equal To
!= Not Equal To
# Not Equal To
> Greater Than
>= Greater Than or Equal To
< Less Than
<= Less Than or Equal To

The Comparison Operators are always evaluated from left to right.

Increment and Decrement Operators

The ++ operator is used to automatically increment a previously declared numeric memory variable by one. The ++ operator must be placed at the beginning of the command line.

Example

i=0
do while i <100
    ++ i
enddo

The -- operator is used to automatically decrement a previously declared numeric memory variable by one. The -- operator must be placed at the beginning of the command line.


Example

i=100
do while i > 0
    --i
enddo

String Concatenation Operator

When dealing with string data types, the + and - operators perform the following concatenation operations:

Operator Operation
+ Concatenate the right hand string to the end of the left hand string.
- Concatenate the right hand string to the end of the left hand string after trimming the left hand string of trailing spaces.

Example

? [Hello] + [ ] + [ World]
Hello World
? [Hello     ] - [ World]
Hello World

String Search Operators

The following String Search Operators are supported in Recital:

Operator Operation
$ Substring is Contained In
| Contains Substring

String Substitution Operator

Execution Operator

Concatenation of Strings and Other Data Types

Summary