Field Data Manager Expressions

  Previous topic Next topic  

Expressions are evaluated in the standard algebraic order of operations. The precedence of operations is controlled by operator type and placement of parentheses. Each operation produces an (internal) intermediate value used in subsequent operations. Parentheses may be used to group operations within expressions. Expressions are evaluated beginning with the inner-most set of parentheses and working through to the outer-most set.

Precedence levels for expression evaluation, from highest to lowest, and left-to-right within each level, are:


Level 1         ( )                                        Parenthetical Grouping

Level 2         -                                        Unary Minus (Negative sign)

Level 3        procedure call                                Gets the RETURN value

Level 4        ^                                          Exponentiation

Level 5        * / %                                          Multiplication, Division, Modulus Division

Level 6        + -                                          Addition, Subtraction

Level 7        &                                          Concatenation

Level 8        = <>                                          Logical Comparisons

Level 9        NOT, AND, OR/XOR                        Boolean expressions

Level 10 Single quotes (apostrophe) 'myexpression' Used for absolute data pictures


Expressions may produce numeric values, string values, or logical values (true/false evaluation). An expression may contain no operators at all; it may be a single variable, constant value, or procedure call which returns a value.


Sting Constants

A string constant is a set of characters enclosed in single quotes (apostrophes). The maximum length of a string constant is 255 characters. Characters that cannot be entered from the keyboard may be inserted into a string constant by enclosing their ASCII character codes in angle brackets (<> ). ASCII character codes may be represented in decimal, hexadecimal, binary, or octal numeric constant format. In a string constant, a left angle bracket ( < ) initiates a scan for a right angle bracket. Therefore, to include a left angle bracket in a string constant requires two left angle brackets in succession. To include an apostrophe as part of the value inside a string constant requires two apostrophes in succession. Two apostrophes ( '' ), with no characters (or just spaces) between them, represents a null, or blank, string. Consecutive occurrences of the same character within a string constant may be represented by repeat count notation. The number of times the character is to be repeated is placed within curly braces ( { } ) immediately following the character to repeat. To include a left curly brace ({) as part of the value inside a string constant requires two left curly braces ({{) in succession.


The ampersand (&) is always valid in a string constant. However, depending on the assignment's destination, it may be interpreted as an underscore for a hot letter (for example, a PROMPT control's display text). In this case, you double it up (&&) to end up with a single ampersand in the screen display.




'string constant'   !A string constant


'It''s a girl!'     !With embedded apostrophe

'<27,15>'           !Using decimal ASCII codes

'A << B'            !With embedded left angle, A < B

'*{20}'             !Twenty asterisks, repeat-count notation

''                  !A null (blank) string


Data Formatting or Pictures

@P        All pattern pictures begin with the @P delimiter and end with the P delimiter. The case of the delimiters must be the same.


<        Specifies an integer position that is blank for leading zeroes.

#        Specifies an integer position.

x        Represents optional display characters. These characters appear in the final result string.

P        All pattern pictures must end with P. If a lower case @p delimiter is used, the ending P delimiter must also be lower case.

B        Specifies that the format displays as blank when the value is zero.


Pattern pictures contain optional integer positions and optional edit characters. Any character other than < or # is considered an edit character which will appear in the formatted picture string. The @P and P delimiters are case sensitive. Therefore, an upper case "P" can be included as an edit character if the delimiters are both lower case "p" and vice versa.

Pattern pictures do not recognize decimal points, in order to permit the period to be used as an edit character. Therefore, the value formatted by a pattern picture should be an integer. If a floating point value is formatted by a pattern picture, only the integer portion of the number will appear in the result.




Picture           Value        Result


@P###-##-####P    215846377    215-84-6377

@P<#/##/##P       103159       10/31/59

@'P(###)###-####P'  3057854555   (305)785-4555

@P###/###-####P   7854555      000/785-4555

@p<#:##PMp        530          5:30PM

@P<#' <#"P        506          5' 6"

@P<#lb. <#oz.P    902          9lb. 2oz.

@P4##A-#P         112          411A-2

@PA##.C#P         312.45       A31.C2