Skip to content

Gt Comparison Mode

Obsolete

The GTfind mode is still supported. Refer to the Find Command for further details.

For Boolean comparisons, you should use the > symbol inside a Boolean expression.

Example

This is obsolete:

If iCount GT 10

This is correct:

If (iCount > 10)

Purpose

To specify "greater than" as the operator for finds and comparisons.

Syntax

With the find command, records can be found in a database file according to the results of comparisons of a value in the record buffer with values in an index to field values in a database file:

move value to df_filename.field
find gt df_filename.field

See Find Command for a description of that command.

Commands and loops can be controlled according to the results of comparisons of the values of two variables using the gt operator:

indicate indicator as variable gt variable

See Indicate Command for a description of that command.

if variable gt variable command

See If Command for a description of that command.

repeat command: command until variable gt variable

See Repeat Command for a description of that command.

while variable gt variable command: command
end

See While Command for a description of that command.

The values of variables are compared in the order in which they are given in the statement. That is, the first-named variable is tested for being greater than the second-named.

What It Does

When used with the find command, gt searches for a value in the index to the database file equal to the value in the fields in the record buffer of which the index is composed. Then the value in the index next greater than the buffer value is used to complete the find. If the index contains no value greater than the standard, then the find is unsuccessful and the predefined indicator found is set to false.

move "BONAPAR" to emperors.last_name
find gt emperors.last_name

In this example, the value of "BONAPAR" is moved to the record buffer field last_name for the database file emperors after emperors has been opened and its record buffer cleared. The subsequent find command finds the first record in emperors whose last_name field is greater than "BONAPAR", using the main index for that field. The field last_name must be indexed.

When used as a find mode by an index containing one or more segments designated "upper case," gt will find a record containing a greater letter value regardless of capitalization in either the record field or the search key. If one or more segments are designated "descending," find gt will actually find lt relative to the record values to produce the desired descending sequence.

When used in comparisons, gt converts the type of the "standard" variable to the same type as the first-named variable and executes the controlled command according to whether the first-named variable is greater than the standard.

indicate prospect as income gt 4000
[prospect] gosub mail_adv

In this example, the indicator prospect is set to true when the value of the variable income is more than 4000. The second line executes the labeled subroutine mail_adv when prospect is true.

while windowindex gt 0
    move 0 to form.5&
    calc (windowindex - 1) to windowindex
loop

In this example, the value of 0 is displayed to windows in image form in descending order until the first window is reached. The loop is executed as long as the value of the predefined variable windowindex is greater than zero. Note the calc command, which decrements the value of windowindex so that it eventually reaches zero.

Notes

  • Find gt commands in a loop will "step through" a database file record by record in ascending order by the index in use from the index value of whatever record is in the buffer at the time the loop is started. This is useful for record-by-record reports and will start at the beginning of the index if the loop is started when the record buffer is clear.

  • For the if, indicate, until, and while commands, DataFlex uses eight comparison mode operators: eq, ge, gt, in, le, lt, ne, and match.

  • For the find command, DataFlex uses five find mode operators: eq, ge, gt, le, lt.

  • gt applies to strings and dates as well as to numeric values. For strings, "greater" means "alphabetically after," and for dates, it means "later than," except for index segments designated "descending," where the opposite occurs.

  • gt may not be used in logical expressions (comparisons enclosed in parentheses). In expressions, > is to be used.