Answer to question 19

Hopefully, you noticed that the function calls are executed for every record, and sometimes even more than once.

For every record, you must go through the select and every time the interpreter must call a function, up to four times in the worst case !!!  Needless to say that this is a waste of CPU resources.

As you can expect from a lesson dealing with parse, this technique will help us to improve the performance a lot by avoiding the repeated function calls :

    do queued()
    parse pull line  1 col1 2   1  w1 . w3 .  1 10 part +20
      select
        when col1='*' then iterate          /* ignore comments */
        when w1='KING' then call chess part
        when w1 w3='FROM BOSS' then call myboss
        when w1='SKIP' then iterate
        otherwise Say 'Invalid card:' line
      end /* select */
   end /* queued */

Let's stress again that a select construct, tests the conditions one by one, in the specified sequence, and the first condition that is true will be executed.  Subsequent conditions will not be tested anymore.

Hit the backward navigation button to return to the lesson.