DelphiScript - Set Operators

Applies to TestComplete 15.69, last modified on November 13, 2024

There are some differences in the use of set operators in DelphiScript and Delphi. In DelphiScript the [...] set operator is not supported. You should use the MkSet function instead. For instance:

DelphiScript

var ppOne, ppTwo;
var z;
...
ppOne : =1;
ppTwo := 2;
z := MkSet(ppOne, ppTwo);

In this example, the MkSet function puts 1 into the second and third bits since the first bit has index 0. So, the value of the z variable is 6 (but not 3).

Instead of the in operator, you should use the InSet function, for example:

DelphiScript

if InSet(ppOne, z) then
Log.Message(...);

See Checking TDBGrid Options From Scripts.

As in Standard Pascal or Object Pascal, sets are implemented as collections of bits. However, because of the implicit type conversions of OLEVariant variables, the resulting sets are treated as integers. Arithmetic operators, +, -, *, <= and >= , cannot be used as set operators. Logical operators must be used in their place. For example:

DelphiScript

z := ppOne + ppTwo;

should be changed to

DelphiScript

z := ppOne or ppTwo;

Note: The mentioned functions: MkSet and InSet work not only in DelphiScript but in all supported languages. For more information see Functions Added to All Scripting Languages.

See Also

DelphiScript Description

Highlight search results