In order for this site to work correctly, and for us to improve the site, we need to store a small file (called a cookie) on your computer.
By continuing to use this website, you agree to our cookies and privacy policy.
Home page Home page Home page Home page
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel


In last month's RTPSeries, we bewailed the fact that RTP21 was not accessible to normal programmers, so this month we look at a system subroutine called COMP which has much of the functionality of RTP21 without requiring a system compiler to use.

Like all of the best routines, COMP is staggeringly simple to use. The multivalued array to be checked is put into @ANS and the comparison to be applied is passed as a parameter to the subroutine. There is no complicated coding system to remember, comparisons are sent as literals as with BTREE.EXTRACT or the query window. COMP then returns in @ANS a multivalued array of true/false flags corresponding to the comparisons requested. Thus if @ANS was set to 1 : @VM : 2 : @VM : 3 and COMP was called with a comparison of ">2", @ANS would be returned as 0 :@VM : 0 :@VM : 1.

The optimum use for this function is in determining how many of a multi-valued set meet certain criteria. As the answer is a true/false array, all we need to so is sum the array to find out how many correct answers we have. So if we had a field containing the ages of a subject's children, and we wanted to find out how many of them were over 18 we would use the following code

0001                 @ANS = {CHILDRENS.AGE}
0002                 CALL COMP(">18")
0003                 NO.OVER = SUM(@ANS)
0004                 CALL MSG("%1% children over 18","","",NO.OVER)

I have tested this routine with the standard operators (=, #, >, < , >=, <=,%,..., ], [, []) and it seems to work. More options may be available, further playing will tell!

(Volume 1, Issue 4, Page 4)
Pixel Footer R1 C1 Pixel