[NOT] BETWEEN

Compares one value to a specified range of values.

Syntax

expression [NOT] BETWEEN expr1 AND expr2

Parameters

expressionAn expression that evaluates to either a number or a character string.
expr1An expression that evaluates to either a number or a character string.
expr2An expression that evaluates to either a number or a character string.

Return Value

Logical

Comments

If any one of expression, expr1, and expr2 is a number, then a numeric comparison is made; otherwise, the comparison is character-based. Note that the AND in a BETWEEN comparison is not the Boolean AND.

A BETWEEN comparison is logically true if expression is greater than or equal to expr1, and less than or equal to expr2.

A NOT BETWEEN comparison is logically true if expression is either less than expr1, or greater than expr2.

Note: The AND in a BETWEEN comparison is not the Boolean AND.

Example

BioDiversity between 500 and 2000

Logically true if the value of BioDiversity lies between 500 and 2000 (inclusive).

See Also

About Conditional Expressions

( ) Parentheses

Alters the order of evaluation of expressions, or groups expressions, or both.

Syntax #1

Alters the order of evaluation in expressions.

(expression)

Within a larger expression, a single expression placed in parentheses changes the order of execution (which normally depends on the precedence of operators).

Parameters

expressionan arithmetic or logic expression

Syntax #2

Groups expressions.

(expression1, expression2)

Parentheses can be used to group several expressions, each of which is evaluated; the grouped expression takes on the value of the last individual expression in the group.

Parameters

expression1any expression
expression2any expression

Comments

Use parentheses to group one or more expressions, each of which is evaluated. The grouped expression takes on the value of the last expression in the group.

Examples

7 * 8 - 5^2
31
7 * (8 - 5)^2
63
not Salary > 30000 or Age < 25

Result: Logically true when Salary is 29,000 and Age is 21.

not (Salary > 30000 or Age < 25)

Result: Logically false when Salary is 29,000 and Age is 21.

w = ( (let x = 5+3), (let y = 5-3), (let z = 5^3), 5.0/3.0 )

Values: x=8, y=2, z=75, w=1.7

See Also

Conventions

How To Construct Logic Expressions

How To Use Logic Expressions

OR

Performs a Boolean OR of two logic expressions.

Syntax

expression1 OR expression2

Parameters

expression1A logic expression using conditional and Boolean operators. If the expression is complex, it must be enclosed in parentheses.
expression2A logic expression using conditional and Boolean operators. If the expression is complex, it must be enclosed in parentheses.

Return Value

Logical, as follows:

Truth Table for Boolean ORExpression1
TrueFalse
Expression2TrueTrueTrue
FalseFalseFalse

Example

The following expression is logically false only if Salary is 30,000 and Bonus is 0. In all other cases, the expression is logically true.

Salary <> 30000 or Bonus <> 0

See Also

About Boolean Expressions

About Conditional Expressions

XOR

Performs a Boolean XOR of two logic expressions.

Syntax

expression1 XOR expression2

Parameters

expression1Any conditional expression or Boolean expression. If the expression is complex, it must be enclosed in parentheses.
expression2Any conditional expression or Boolean expression. If the expression is complex, it must be enclosed in parentheses.

Return Value

Logical as follows:

Truth Table for Boolean XORExpression 1
TrueFalse
Expression 2TrueFalseTrue
FalseTrueFalse

Comments

Performs a Boolean XOR (exclusive OR) of two logic expressions.

Example

LastName = “Smith” xor FirstName = “John”

The entire expression is logically true only if LastName is Smith or FirstName is John, but not both; otherwise, the entire expression is logically false.

See Also

About Boolean Expressions

About Conditional Expressions

OR

=, <, <=, <>, >, >= (Condition)

Compares two expressions and returns a value of “true” or “false”.

Syntax

expression1
=
<
<=
<>
>
>=
expression2

Parameters

expression1any value expression
expression2any value expression

Return Value

Logical

Comments

In a conditional expression, the less than sign (<) compares the expressions to its left and right, and is logically true if the expression on the left is “smaller” than the expression on the right; otherwise, it is logically false.

In a conditional expression, the less than or equals sign (<=) compares the expressions to its left and right, and is logically true if the expression on the left is “smaller” than or equal to the expression on the right; otherwise, it is logically false.

In a conditional expression, the not equals sign (<>) compares the expressions to its left and right, and is logically true if they are not equal; otherwise, it is logically false.

In a conditional expression, the equals sign (=) compares the expressions to its left and right, and is logically true if they are equal; otherwise, it is logically false.

In a conditional expression, the greater than sign (>) compares the expressions to its left and right, and is logically true if the expression on the left is “larger” than the expression on the right; otherwise, it is logically false.

In a conditional expression, the greater than or equals sign (>=) compares the expressions to its left and right, and is logically true if the expression on the left is “larger” than or equal to the expression on the right; otherwise, it is logically false.

Examples

case
when GeoLocation = "New York"
... commands ...
otherwise
... more commands ...
endcase
while var1 < 11
... commands ...
var1 = var1 + 1
endwhile
DayCare = {"subsidized" where GIncome <= 22000, "not subsidized"}
case
when GeoLocation <> "Madrid"
... commands ...
otherwise
... more commands ...
endcase
case
when GoodsValue > 2000
... commands ...
otherwise
... more commands ...
endcase
case
when Age >= 65
... commands ...
otherwise
... more commands ...
endcase

See Also

About Conditional Expressions

About Data Types

\ (Escape)

Causes the following character to be treated literally, or as a hex code in a character string; indicates continuation of a command on the subsequent line.

Syntax #1

Causes the character that follows it in a string to be treated literally.

\char

Parameters

charany single character that is to be treated literally in a character string

Syntax #2

Causes certain characters that follow it in a string to be treated as hexadecimal code.

\char1char2

Parameters

char1either digits from 0 to 9, or letters from A (a) to F ( f), that together comprise a hexadecimal character code
char2either digits from 0 to 9, or letters from A (a) to F ( f), that together comprise a hexadecimal character code

Syntax #3

Indicates the continuation of a command onto a subsequent line.

commandstart \
remainder

Parameters

commandstartany portion, from the beginning, of one command
remainderthe remaining portion(s) of the same command

Comments

In a character string, the escape operator causes the next character to be treated literally or as a hex code. Outside of a character string, it indicates that a command continues on the next line.

Example

"This is a quote (\"); this is a backslash (\\)"
output "\0F"
let x = 10 \
    y = 5 \
    z = 2

See Also

About Character Literals

% (Wildcard)

Used with the LIKE operator to construct patterns for matching.

Comments

Used with the LIKE operator in logic expressions, the % wildcard matches zero or any number of subsequent characters when the pattern on the right is compared to expression1.

Example

"_ ob%"

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

compute Employees where LastName like "_ a%n"

Processes all records whose LastName values are three characters or more, the second character being an a and the last character being an n.

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.)

find Parts where PartDesc like "%\\%"

Finds parts whose part description contains a backslash.

FirstName like $ concat(" S_e%p", SuffixVariable)

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

The LIKE Operator, The %Wildcard and SQL Servers

The LIKE Operator with %Wildcard sometimes operate differently in SQL servers than in ZIM. The following construction:

find Parts where PartDesc like "%e"

in some SQL servers might only retrieve records when the PartDesc ends exactly with an “e” in the last position of the field. If PartDesc is 5 characters long, the “rode” and “are” will not be retrieved, whereas “there” and “force” will be.

To solve this situation, the above construction must be written this way:

find Parts where $trim(PartDesc) like "%e"

See Also

Conventions

How To Construct Logic Expressions

How To Use Logic Expressions

$DDEFunction

Invokes and interacts with DDE services

Syntax

$DDEFunction ( p1, p2, p3, p4, ... )

Parameters

p1return type, longint
p2command, longint
p3server handle, longint
p4application command, string

Comments

Where p1, p2, and so on, indicate the desired DDE service and the data required by that service. The first parameter, p1, is entirely for Zim’s benefit and defines the data type of the value returned by the DDE service. The second parameter, p2, determines the desired service and the remaining parameters are used by the DDE service itself.

The first parameter, p1, is dependent on the DDE service you invoke and the application with which you are communicating. When using $DDEFunction, specify p1 in such way that sufficient space is allocated for the return value. For example, if you use $DDEFunction to invoke a DDE service that returns a long integer result, then the p1 you provide must be of type longint as well. If p1 were of type char 10, $DDEFunction would expect a result value of up to 10 characters in length.

The second parameter, p2, is a number that indicates the DDE service to invoke. The possible values for p2 are shown in the table below. The p2 parameter must be of type longint or int.

DDE Servicep2 ValueDescription
CONNECT1Start a conversation with an application and topic.
POKE2Set an item to a value.
DISCONNECT3Terminate a conversation.
PEEK4Retrieve the value of an Item.
EXECUTE5Execute an application.

The remaining parameters, p3, p4, and so on, are dependent on the DDE service you invoke and the application with which you are communicating.

See Also

About DDE Services

$lastmember

Returns the number of members in a result set.

Syntax

$lastmember(setname)

Parameters

setnameA character string or an expression that evaluates to a character string, being the name of a result set.

Return Value

Number with no decimal places.

Comments

$lastmember returns the (numerical) position of the last member in the specified result set (in effect telling you how many members the set contains). To explicitly specify the current set, use “CurrentSet”, including the quotation marks, as the function is expecting a character string, and CurrentSet is a reserved word.

To ensure against unexpected results, choose set names carefully. At run time, the software distinguishes sets only by their names, even if they are permanent set names created in different application directories.

If, for example, you produce a set called Set1 in directory PersonnelData, and later you produce another set called Set1 in directory TestData, the second version of Set1 replaces the first version. Function $lastmember works on only the most recent version of the set.

Example

To display the number of members in Set1, enter

output ($lastmember("Set1"))
25 % Displays the number of members in Set1.
procedure ProcessSet ()
   if $lastmember("EmpSet") = 0
      return
   endif
   ...more commands...
endprocedure

If a procedure processes a set created elsewhere, it is not necessary to pass the size of the set as a parameter; $lastmember can be used instead.

See Also

$currentmember

$SetCount

About Functional Expressions

$center (or $centre)

Centers a non-blank character string.

Syntax

$center(string) | $centre(string)

Parameters

stringa character string, or an expression that evaluates to a character string

Return Value

Character string, consisting of string centered in a space $length(string) characters long. Leading or trailing blanks in string are ignored during centering. If string contains an odd number of characters, it centers with a bias to the left.

Comments

String is centered in an area that is $length(string) characters long. All leading and trailing blanks in string are ignored. If string contains an odd number of characters, the string is centered with a bias to the left.

Example

$center("abcde ")

Evaluates to ” abcde “. Centering five characters in a 10-character field produces a string that contains two spaces on the left and three spaces on the right.

$center(var3)

Evaluates to ” 3 “. If var3 is an INT variable whose value is 3, the resulting value is a string of eight characters, with three spaces to the left of the 3 and four spaces to the right. (INT values occupy eight character spaces when converted to character strings.)

See Also

$leftjustify

$length

$rightjustify

About Character Literals

About Data Types

About Functional Expressions

pt_BRPortuguese