How To Use the Null Property

When certain atomic expressions (variable name, field name, form field name, or formal parameter name) are used before being assigned values, or if the values are unknown, those expressions are considered to be $Null.

$Null is a property indicating a state of valuelessness; $Null is not itself a value. The null string is a value and is therefore not the same as the $Null property.

An arithmetic or functional expression that includes a $Null argument or operand always evaluates to $Null.

A logic expression that includes a $Null operand always evaluates to $False.

Because $Null is not a value, you cannot use the conditional operators = (Equals) and <> (Not Equals) to determine if an expression is $Null. Instead, the operator IS [NOT] [$]NULL is used as shown in the following example:

Salary is $null

Salary is not $null

Note: $Null can be written without the dollar sign.

How To Name Objects

Names for objects defined in the Object Dictionary must conform to the following conventions:

  • The name can be from 1 to 18 characters in length.

  • The name can contain only letters (a-z, A-Z), digits (0-9), dollar signs ($), and underscores (_).

  • The name must begin with a letter or a dollar sign.

  • Most names must be unique among objects of the same type in the same application directory. (Note that the software is case-insensitive: ABC and abc are the same name.) For more information, see the documentation for your operating system.

  • The name does not duplicate words reserved to the software’s use, such as a command or function keyword (CREATE, $isalphabetic).

Examples of Object Names

Examples of valid names are

  • myfile98

  • x99

  • a

  • ProjectControl56

  • x_7b

  • date

  • $i

Compare these to the following invalid names:

  • 98myfile

  • 99

  • a+

  • x%@

  • ProjectControl 56/8

  • $Date

 

How To Construct a Validation Rule for Numeric Fields

The available pattern symbols for constructing numeric validation rules are

  • digits used to form specific numbers. Numbers indicate value(s) to which the input data must conform.

  • +, used to specify the sign of a number.

  • period used as a decimal point.

The available syntax characters for constructing numeric validation rules are

Denote a range of numbers.

|

Separates alternative numbers or ranges of numbers.

Examples of Numeric Validation Rules

The following table contains examples of numeric validation rules, and the values that can be legal or illegal under those rules:

Validation Rule

Legal Value

Illegal Value

1|2|3|5

1 or 2 or 3 or 5

0 or 4 or 6

10-20

From 10 to 20, inclusive.
10.123 is also legal. (Use DataMask to control the number of decimal places permitted in the field.)

0-9 or 21

10-20|100-200

From 10 to 20, or from 100 to 200, inclusive

0-9 or 21-99 or 201

-30–5|1|1.3-1.7

From -30 to -5, or 1, or from 1.3 to 1.7

-4-0 or 1.8 or 2

 

How To Call Procedures

The syntax of a call to a procedure is

procname («expression»)

Parameters

procname

The name assigned to the procedure in its PROCEDURE or LOCALPROCEDURE command.

expression

Any value expression.

Comments

The list of expressions must be enclosed in parentheses; even when no expressions are required, the parentheses must still appear.

At the prompt level, you can issue a call to the main procedure of any procedure program.

Within a procedure program, you can issue a call to

  • any local procedure in the current program

  • the main procedure in the current program

  • the main procedure in any other procedure program

Any procedure in a procedure program can issue a call to itself.

In a call to a procedure, you must supply one expression for each parameter specified in the PROCEDURE or LOCALPROCEDURE command that describes the called procedure. The number and type of expressions listed in the call to a particular procedure must match the number and type of parameters in the PROCEDURE command in order for the procedure to execute. The value of expression can be assigned to the corresponding parameter (IN parameters), or expression can take on the value of the corresponding parameter when the procedure ends (OUT parameters), or both (INOUT parameters).

When you specify more than one expression, each must be separated from the next by a comma.

 

See Also

Conventions

LOCALPROCEDURE

PROCEDURE

TRANSFORM

How To Use Logic Expressions

A logic expression is an expression that, when evaluated, yields either a $True or a $False result.

Logic expressions are subdivided into conditional expressions and Boolean expressions.

How To Construct Conditional Expressions

A conditional expression is a complex logic expression that consists of two value expressions and an associated conditional operator. The conditional operator performs a designated comparison of the value expressions and returns the result $True or $False. Conditional expressions can be combined into Boolean expressions.

The conditional operators are

= (equals)

<> (not equals)

< (less than)

> (greater than)

<= (less than or equals)

>= (greater than or equals)

[NOT] BETWEEN

[NOT] IN

[NOT] LIKE

Examples of Conditional Expressions

EmpNum < 1254

DeptNum >= EmpNum

First Name = “Smith”

DeptDesc <> “Sports”

EmpNum between 1000 and 2000

LastName like “%ith%”

Event.EventName in (“F1”, “F2”, “Escape”)

ProdCode not between 542 and 863

LastName not in (“Smith”, “Jones”)

FirstName not like “Sm%”

How To Use Boolean Expressions

A Boolean expression is a complex logic expression that consists of one or more conditional expressions and an associated Boolean operator. The Boolean operator performs a Boolean operation on the $True or $False values returned by the conditional expression(s) and returns the result $True or $False.

The Boolean operators are

AND

OR

XOR

NOT

Examples of Boolean Expressions

LastName = “Allan” or FirstName = “Allan”

DeptNum = “Sports” and Salary > 45000 and LastName = “Smith”

not Salary > 45000

See Also

$and

$not

$or

Truth Tables

How To Use Data Masks

Three types of data masks are available: output masks, display masks and input masks.

Output Masks

An output mask is used to format the data value of a field in a list, report or output command.

The output mask of a field is defined by its FieldMask attribute.

An explicit output mask can be applied to a field, and also to a form field or to any data value, using either:

  • the $mask function;
  • the MASK option in Zim Reports;

Displays Masks

A display mask is apparent only when a data value is being displayed in an entry field.

When data is being input to a display-masked entry field, the display mask will be substituted by the input mask (if defined).

Once data input is completed, the data value of the form field will be presented formatted by the display mask.

The display mask for an entry field is defined by its DataMask attribute.

Input Masks

When defined, an input mask is presented when data is being typed in an entry field (i.e., the entry field is available and has focus);

If the input mask is not defined, the display mask will act as the input mask.

In either case, the value of the input data must conform to the effective input mask , as well as to the validation rule (if defined) in effect for that entry field.

The input mask for an entry field is defined by its WdgInputMask attribute.

Masks and Data Types

For a more detailed explanation of mask patterns and their relation to data types, see Masking.

How To Construct a Validation Rule for Alphanumeric Fields

The available pattern symbols for constructing alphanumeric validation rules are

  • A stands for any letter (A-Z, a-z)

  • X stands for any letter or digit (A-Z, a-z, 0-9)

  • 9 stands for any digit (0-9)

  • Z stands for any digit or blank (0-9, the space character)

  • (all others) exact match. To obtain an exact match for A, X, 9, or Z, add the escape character (e.g., A, X, 9, Z)

The available syntax characters for constructing alphanumeric validation rules are

[ ]

Encloses a set of alternative characters. (Note: All characters inside brackets are taken literally; for example, A is the letter “A”, not the pattern symbol A.)

Used inside brackets to denote a range of characters.

|

Separates alternative validation patterns

A telephone number can consist of a three-digit area code enclosed in parentheses, as well as a seven-digit number containing a hyphen, or just the seven-digit number and hyphen. The first digit of the area code must fall in the range 2 through 9; the second digit must be 0 or 1; and the third digit is unrestricted. The first digit of the prefix must fall in the range 2 through 9. The remaining numbers are unrestricted. So the rule can be expressed as follows:

([2-9][0-1]9)[2-9]99-9999|[2-9]99-9999

Input values that are accepted as legal include 212-643-9763 and 643-9763; input values that are rejected include 222-643-9763 and 143-9763.

Examples of Alphanumeric Validation Rules

The following table contains examples of alphanumeric validation rules and the values that might be legal or illegal under those rules:

Validation Rule

Legal Value

Illegal Value

AB

qB

q”

XX-XXXX

AL-9632

$63.09

Q[L-P]A

QLA or QMA or QPA

QRA or qLa or QPB

[ACEG]

A or C or E

B or D or F

[Ax-zB]

A or y or B

a or Y or b

A|9

m or 3 or Q

? or $ or %

Y|N

Y or N

A or 5

 

How To Construct Logic Expressions

Logic expressions represent true or false circumstances. Logic expressions typically consist of at least two arguments (usually value expressions) combined using conditional operators (conditional expressions), Boolean operators (Boolean expressions), or both. Logic expressions can be quite complex. Parentheses can be used to explicitly control the order of evaluation in complex logic expressions.

When a statement contains a logic expression, the software evaluates the expression to determine if it is logically true or logically false.

Writing Expressions

The conditional operators, Boolean operators, and parentheses can be combined to create long, complex expressions. These logic expressions are evaluated based on the standard rules of precedence. Parentheses alter the order of evaluation.

Spaces between operands and symbol operators can be used for clarity, but are not required; spaces must appear, however, between operands and word operators.

For example, Salary > 20000 and Salary>20000 are equivalent, but notSalary>45000 cannot be substituted for not Salary>45000.

Data Types

Logic expressions always yield a logical true/false result.

The operands used in any single conditional expression should preferably be of the same data type; however, non-matching types are converted, if necessary, to perform the comparison specified by the operator. The operands used in any single Boolean expression must have logic values (i.e., their values must be logical true/false).

Pattern Matching In Conditional Expressions

The conditional operators LIKE and = (equals) can be used with special wildcard characters to perform pattern matching of character strings.

The available LIKE wildcards are

_ (underscore)

The underscore matches any single character.

% (percent sign)

The percent character matches any sequence of zero or more characters.

(escape character)

The backslash indicates that the next character (usually the underscore or percent sign) is to be taken literally. However, because a backslash is also used as the software’s universal escape operator in character strings, the LIKE backslash must itself be preceded by an escape backslash as shown in the following example:

find Parts where PartNo like “_ _\_%”

Examples of Pattern Matching in = Logic Expressions

DeptNum = “D56”?

Logically true if the department number begins with the characters D56. Note that the question mark must appear outside the string.

RemarkField = “Smith?”

Shows the question mark being used literally in a string. (The characters appear inside the quotation marks.) The expression is logically true only if Remarkfield contains the exact characters Smith?.

Surname = fCustomer.LastName?

Shows how the wildcard can be attached directly to an atomic expression employing a variable, local variable, form field, or formal parameter, provided the object is of a character data type. (Trailing blanks in the specified object are trimmed for pattern-matching purposes.)

Examples of Pattern Matching in LIKE Logic Expressions

“_ob%”

Matches any character string whose second and third letters are ob, followed by zero or more characters (i.e., “Robert”, “Bob”, “Cobbler”, etc.).

Grade like “100\%”

Shows the percent sign being used literally in a string. (The first backslash “escapes” the second backslash, which, in turn, “escapes” the percent sign, turning it into a literal character.)

FirstName like $concat(“S_e%p”,SuffixVariable)

Assuming that SuffixVariable is “%”, the above expression is logically true if FirstName matches the pattern S_e%p%.

About Macros

A macro is a dynamically declared name that represents a character string. When a macro call is encountered in an application program the macro call is replaced by the current character string value of the macro. Macros are sometimes called replacement parameters or substitution variables.

The following topics discuss how to work with macros in applications:

  • Availability of macros

  • How macros acquire values

  • Macro Substitution

  • Macros and Compiled Programs

About Macros

A macro is a dynamically declared name that represents a character string. When a macro call is encountered in an application program the macro call is replaced by the current character string value of the macro. Macros are sometimes called replacement parameters or substitution variables.

The following topics discuss how to work with macros in applications:

  • Availability of macros
  • How macros acquire values
  • Macro Substitution
  • Macros and Compiled Programs

The Availability of Macros

You can declare two different kinds of macros during an application session:

  • global macros
  • local macros

Global Macros

The name declaration for a global macro uses the following syntax:

<name>

where

namea valid identifying name for the macro
< and >macro name delimiters make the macro easy to distinguish

After a global macro is declared, you can reuse it in any application program for the duration of the application session. When the session ends, the macro is no longer available.

Local Macros

The name declaration for a global macro uses the following syntax:

<n>

where:

na number from 0 to 9
< and >macro name delimiters make the macro easy to distinguish

Every procedure has its own set of ten local macros, <0> through <9>. You can use a local macro only while the procedure to which it belongs continues to execute. Once execution control transfers elsewhere, the local macros particular to that procedure are discarded.

Examples

Consider a global macro, . If you define to represent the character string list all, then the statement

# Documents

is interpreted as

list all Documents

# is the macro call that is replaced by the character string the represents, list all. The number sign (#) is the macro call indicator.

If you redefine to represent the character string ENT, then the statement

list #s format #Name

is interpreted as

list ENTs format ENTName

Macros and Compiled Programs

Macro substitution takes place only when the software is parsing a source (uncompiled) program.

During compilation, the software parses the source code and performs macro substitution based on current macro values. The resulting commands are then compile and stored in compiled form.

When the compiled program is executed, its source code is not parsed again. Therefore, changes to macro values in the interim are not reflected when the compiled program is executed.

For this reason, programs that use macros should not normally be compiled.

pt_BRPortuguese