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

$addmonths

Calculates a date value by adding months to (or subtracting months from) a specified date value.

Syntax

$addmonths(date,number)

where

datea date, or an expression that evaluates to a DATE data type
numbera number, or an expression that evaluates to a number

Return Value

Number, representing a DATE value.

Comments

Use $addmonths to perform arithmetic with date values. The $addmonths function calculates a date value by adding a number representing months to a date value. If number is negative, the effect is to subtract the months from the date.

The + (add) and – (subtract) operators can be used to achieve the same results.

If date or the result of the $addmonths expression is an invalid date (e.g., 19930231), it is adjusted to produce a valid date (e.g., 19930228).

Example

If $Date has the value 19981225, then:

$addmonths($date,3)

Evaluates to 19990325.

$addmonths($date,-3)

Evaluates to 19980925.

$addmonths($date,20)

Evaluates to 20000825.

$addmonths(19980131,1)

Evaluates to 19980228 (note truncation).

See Also

$adddays

$addweeks

$addyears

$day

$dayname

$todate

$weekday

+ (Add/Positive)

About Functional Expressions

Arithmetic with Dates

$random

Generates a pseudo-random number, uniformly distributed within the range 0 to 1.

Syntax

$random(number)

Parameters

numbera number, or an expression that evaluates to a number, that acts as a seed for the random number generator

Return Value

Number, with the same number of decimal places as number.

Comments

Use $random to generate a series of random numbers, by calling the function first with a seed value, and thereafter with $Null. The value returned by $random is a number in the range 0 to 1, with the same number of decimal places as number.

To pass the null property to $random, create a variable of a number data type (INT, LONGINT, VASTINT, numeric) and with the desired number of decimal places. Use this variable on subsequent calls to $random after seeding. (Remember that an uninitialized variable is always $Null.)

If you seed the random number generator with the same number on two or more different occasions, you obtain the same series of “random” numbers on the first call and subsequent ($Null) calls to $random.

Under some operating systems, the seed number is ignored; an internally generated seed is used instead.

When number is $Null, the random number generator is not reseeded.

Example

let seed = 9.999
let i = $random(seed)  % i might be set to 0.798 here
let seed = $null
let i = $random(seed)  % i might be set to 0.768 here
let i = $time
let i = $random(i)       % first call
  :
let i = $random(UninitVariable) % subsequent calls

Notice that $random($time) always returns 0 or 1, because $Time has no decimal places. Variable i is used to provide the necessary decimal places.

$right

Extracts a segment from the end of a character string.

Syntax

$right(source,length)

Parameters

sourcea character string, or an expression that evaluates to a character string
lengtha number, or an expression that evaluates to a number

Return Value

Character string, consisting of length characters from source, starting length character positions from the end of source.

Comments

Use $right to produce a string consisting of length characters from source, starting length character positions from the end of source.

If source is not of a character data type, it is converted to a character data type before the function is applied.

If length is zero or negative, the result is the null string.

If length is longer than source, the result is source.

Example

$right("abcdefgh",5)

Evaluates to “defgh”.

$right(1234,2)

Evaluates to “34”.

$right(1234567890,8)

Evaluates to “34567890”.

See Also

$concat

$delete

$insert

$left

$position

$replace

$substring

$translate

About Character Literals

About Functional Expressions

Conversion Between Data Types

pt_BRPortuguese