User Tools

Site Tools


formula_editor.htm
Navigation:  User's Guide and Tutorials > Writing Clarion Code >====== Formula Editor ====== Previous pageReturn to chapter overviewNext page

If you are new to Clarion or the Clarion Language, there is a powerful utility available to you that is built-in to the Application Generator called the Formula Editor. As a matter of fact, its ease of use causes many experienced users to continue to use it regularly.

The Formula Editor helps you to quickly generate language statements or structures that assign a value to a variable. You can use the Formula Editor to create unconditional or conditional assignments.

·An unconditional assignment assigns the evaluation of an expression to the variable you specify: variable = expression. For example, a variable called GrossPrice might receive the result of adding two variables called BasePrice and Tax.

·A conditional assignment places multiple possible assignments within a structure that executes only one of them. The Formula Editor builds IF structures and CASE structures for this purpose. The assignment statement executed depends on the evaluation of the IF or CASE condition. For example, a conditional variable called “Tax” could equal 0 when “Taxable” (the IF condition) evaluates as false, or “Tax” could equal Price times TaxRate if “Taxable” is true.

The Formula Editor dialog provides access to data dictionary columns, as well as global and local memory variables, and helps you create syntactically correct expressions. This is its prime advantage: automatic syntax checking.

To create an expression, you press buttons to add expression components to the Statement line. You can also enter your expression then check the syntax upon completion.

Let's quickly review the components of a Clarion expression in the next section.

Expressions

An expression is made up of two types of components: operands and operators. Operators perform an operation (such as addition, subtraction, etc.) on one or more operands of the expression. Operands are the components on which operations are performed. Operands either contain or return a value. Constants, data dictionary columns, memory variables, and functions are examples of operands. An operand can be made up of more than one component, such as a function and its parameters.

The Formula Editor lets you choose operators and operands, and then insert them into the Statement line.

The sections below lists all the components used in Clarion expressions.

Math Operators

+ Plus sign: Adds two operands together.
- Minus sign: Subtracts one operand from another.
* Asterisk: Multiplies one operand by another.
/ Slash: Divides one operand by another.
% Percent sign: Returns the remainder from a division operation (modulus division).
Caret: Raises one operand to the power of the other.
( ) Parentheses: Groups components together within an expression.

Logical (Boolean) Operators

= Equal: Evaluates whether one expression is equal to the other.
<; Less Than: Evaluates whether one expression is less than the other.
> Greater Than: Evaluates whether one expression is greater than the other.
<;> Not Equal: Evaluates whether one expression is not equal to the other.
>= Greater or Equal: Evaluates whether one expression is greater than or equal to the other.
<;= Less or Equal: Evaluates whether one expression is less than or equal to the other.
AND Connects two logical expressions together. For an expression containing an AND to be true, both expressions of the AND must be true.
OR Connects two logical expressions together. An expression containing an OR is true if either expression of the OR is true.
XOR Connects two logical expressions together. An XOR expression is true if either expression is true, but not both.
NOT Reverses the evaluation of an expression.
~ Reverses the evaluation of an expression.

String Operators

&amp; Ampersand: Appends one text string to another.

Operands

Data Includes data dictionary columns, global, and local memory variables.
Functions All of the built-in functions of the Clarion language. These functions all perform some operation on parameters (other operands) and return a value.
User Any FUNCTION in your application. These functions perform some operation on parameters (other operands) and return a value.
Constant Text You can type constant text surrounded in single quotes ( 'A' ) on the Statement line.
Constant Number You can type constant numbers on the Statement line. Constant numbers can be represented in any valid format, such as Decimal (1 or 1.2345), Scientific Notation ( 22e4), Binary (0101b), or Hexadecimal (1AFFh).

Example Expressions

Lastname &amp; ', ' &amp; FirstName !concatenated string constants &amp; variables
ABS(Amount) * 100 !function, numeric variable &amp; constant
TaxCode = True AND Amount > .25 !Boolean with variables &amp; constants

Using the Formula Editor

The Formula Editor consists of three dialog boxes:

Formula Manages all formulas you have created for the procedure.
Formula Editor Creates simple assignment statements.
Conditionals Creates conditional structures (IF..THEN or CASE..OF).

Formula Dialog

Formulas.jpg

See the Formula Dialog core help topic for a detailed look at the prompts and options on this window.

Formula Editor Dialog

FormEdit.jpg

See the Formula Editor Dialog core help topic for a detailed look at the prompts and options on this window.

Next: Advanced Topics

formula_editor.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1