* Copyright (c) 1986, 1993
* The Regents of the University of California. All rights reserved.
* This module is believed to contain source code proprietary to AT&T.
* Use and redistribution is subject to the Berkeley Software License
* Agreement and your Software Agreement with AT&T (Western Electric).
static char sccsid
[] = "@(#)selunit.c 8.1 (Berkeley) 6/6/93";
char fnam
[80], s
[80], zb
[200];
int diff
[20], i
, k
, m
, n
, best
, alts
;
if (gets(dobuff
) == NULL
)
if (strcmp(dobuff
, "bye") == 0)
f
= scrin
; /* use old lesson to find next */
sprintf(fnam
, "%s/%s/L%s", direct
, sname
, level
);
fprintf(stderr
, "Selunit: no script for lesson %s.\n", level
);
while (fgets(zb
, 200, f
)) {
if (strcmp(zb
, "#next")==0)
printf("Congratulations; you have finished this sequence.\n");
for(i
=0; fgets(s
, 80, f
); i
++) {
sscanf(s
, "%s %d", posslev
[i
], &diff
[i
]);
/* cycle through lessons from random start */
/* first try the current place, failing that back up to
last place there are untried alternatives (but only one backup) */
alts
++; /* real alternatives */
if (abs(diff
[m
]-speed
) < abs(diff
[best
]-speed
))
/* lessons exhausted or missing */
printf("Sorry, there are no alternative lessons at this stage.\n");
printf("See someone for help.\n");
strcpy (dobuff
, posslev
[best
]);