1: #include "../h/rt.h"
2:
3: /*
4: * e1 to e2 by e3 - generate successive values.
5: */
6:
7: toby(nargs, arg3, arg2, arg1, arg0)
8: int nargs;
9: struct descrip arg3, arg2, arg1, arg0;
10: {
11: DclSave
12: long from, to, by;
13:
14: SetBound;
15: /*
16: * e1 (from), e2 (to), and e3 (by) must be integers. Also, e3 must
17: * not be zero.
18: */
19: if (cvint(&arg1, &from) == NULL)
20: runerr(101, &arg1);
21: if (cvint(&arg2, &to) == NULL)
22: runerr(101, &arg2);
23: if (cvint(&arg3, &by) == NULL)
24: runerr(101, &arg3);
25: if (by == 0)
26: runerr(211, &arg3);
27:
28: /*
29: * Count up or down (depending on relationship of from and to) and
30: * suspend each value in sequence, failing when the limit has been
31: * exceeded.
32: */
33: while ((from <= to && by > 0) || (from >= to && by < 0)) {
34: mkint(from, &arg0);
35: suspend();
36: from += by;
37: }
38: fail();
39: }
40:
41: Opblock(toby,3,"toby")
Defined functions
toby
defined in line
7; used 1 times