Navigation:  MCL Reference > Arguments and Variables of MCL functions >

When to use the While keyword

Print this Topic Previous pageReturn to chapter overviewNext page

The following HrAverage('HrRating( )') returns the average Jockey Club Rating of a horse.

HrAverage('HrRating( )')

 

When there is no MCL conditions, the function will do the average on the whole set of past records. If you want to get the average rating of the horse in only the races within the last 180 days (HrDaysAgo( )<=180), you may rewrite the function as follows:

HrAverage('HrRating( )',,'For HrDaysAgo( )<=180')

 

However, in the MCL condition expression of the example above, only For is used. When there is only For and no While in an MCL condition, RaceMate will scan all history records to filter out those satisfying the For criterion. You will find that rewriting the above function as follows will yield a much faster calculation speed.

HrAverage('HrRating( )',,'While HrDaysAgo( )<=180')

 

RaceMate will scan the past records backwards one by one. Once RaceMate finds the record does not meet the criterion specified by the While condition, scanning will stop and result will be returned immediately.

 

Important: If both For and While clauses exist in the condition argument, please place the For clause before the While clause.

 


Page url: http://www.racematenet.com/english/help/index.html?when_to_use_the_while_keyword.htm