CT function

<< Click to Display Table of Contents >>

Navigation:  User guide > Logic >

CT function

The CT function can be used in simple tests. It counts the number of bits and codes in a list of cols, mvars and fields.

CT is a non-standard CL function; its name is not preceded by a % sign, and it can only be used in simple tests. Consequently it is described here rather than in the chapter on functions.

The following tests are allowed using the CT function:

count test - true if the list contains:

CT (list)/n  exactly n bits true

CT (list)/n1..n2  number of true bits range given

CT (list)/>n  more than n bits true

CT (list)/<n  less than n bits true or no bits true

 

The list consists of mvars, cols and fields separated by commas. Cols may be masked; that is, a mask may follow the col, separated by a colon. In this case, only the codes in the mask are counted.

IMPORTANT: if referring to cols or fields you must use RCP BINARYDATA.

A CT test can be negated (i.e. its sense reversed) by inserting the letter N immediately before the test (after the /).

Examples of CT usage:

ct($123,$124)/1,

ct($mult)/n2,

ct($321:vx,$322:vx,$323:vx9)/>0,

As well as being used as a test in definitions, the result of the count can also be stored in an ivar:

di $inum=ct($123,$124),

di $cnt=ct($mult),

di $howmany=ct($321:vx,$322:vx,$323:vx9),