Increments a multi-digit counter using non base-10 arithmetic.
||Specifies the number of values required for the counter; default 2|
||Saves the number of counter values that could be formed|
||Specifies the direction of the sequence of increments to the counter (
||Provides the starting values for the digits in the counter|
||Can provide values to define the end of the sequence of counter values|
||Specifies the amount by which to increment each digit of the counter|
||Specifies the base of the numbers used for each digit|
||Saves the sequence of values generated for each digit|
COUNTER is useful if you want to increment a counter made up of several digits that recycle to limits that may be different from ten. For example, times in seconds, minutes and hours, or measurements in inches, feet and yards.
The parameters provide details of the digits in the counter, all in scalars. The
BASE parameter specifies the base of the numbers used for each digit (e.g. 60 for seconds and minutes, and 24 for hours). The
START parameter supplies the starting values of the digits, ranging from zero to
BASE minus one. The
STEP parameter specifies the size of the increment for each digit. The digits are updated from the right-hand side and, when one goes beyond its limit, the next one is incremented by an extra value of one for an ascending sequence, or minus one for a descending sequence. The
DIGITSEQUENCE saves the sequence of values formed for each digit of the counter, in variates.
END parameter can specify values to define the end of the sequence. If a value is specified for every digit, the sequence ends when the next set of digits would go beyond those supplied by
END for an ascending sequence, or below for a descending sequence. (See the
DIRECTION option.) Otherwise, the sequence ends when all the digits would go beyond their limits:
BASE minus one for an ascending sequence, or zero for a descending sequence.
NREQUIRED option specifies the number of values that are required for the counter. The default is 2, i.e.
START and one other. The
NFOUND option can save the number of values that have been formed. The
DIRECTION option controls whether the sequence of counter values should be regarded as ascending or descending, when checking for the end of the sequence. The default is ascending.
Commands for: Program control.
" Example 1:5.4.4 " " Count in inches from 1 foot 11 inches to 2 yards " COUNTER [NREQUIRED=99] 1,0,11; END=2,0,0; STEP=0,0,1;\ BASE=1760,3,12; DIGITSEQUENCE=yard,foot,inch PRINT yard,foot,inch; DECIMALS=0