Alime.221 net.sources utzoo!decvax!harpo!floyd!vax135!lime!martin Thu Apr 15 18:33:39 1982 scatter away those rainy days #include /* * SCATTER. This program takes the first 23 lines from the standard * input and displays them on the VDU screen, in a random manner. * The program is set up to work on HP262X terminals. Each run of the * program is different. * i do not use /etc/termcap et all, because this was a small program * written on a rainy day. * The program has no worth while use except for "who|scatter" and * "ls - l | scatter" when you are boared. * * martin levy. HO-2787. houxg!lime!martin. */ char s[23][80]; /* Screen Array */ main() { register int i=0,j=0; register char c; int char_count=0; long t; char buf[BUFSIZ]; setbuf(stdout,buf); init(); while( (c=getchar()) != EOF && i < 23 ) { if(c != '\n') { if(c == '\t') j = (j|07)+1; /* Adjust for tab char */ else { s[i][j++] = c; /* Place char in screen array */ if(c != ' ') char_count++; } } else { j=0; i++; /* Newline in array */ } } /* screen read in */ time(t); srand((int)(t&0177777L)); /* Seed the random number gen */ clear(); /* clear screen */ while(char_count) { i=rand()%23; j=rand()%80; if(s[i][j] != EOF && s[i][j] != ' ') { printf("%s%c",cursor(i,j),s[i][j]); s[i][j]=EOF; char_count--; } } printf("%s",cursor(23,0)); } init() { register int i,j; for(i=0;i<23;i++) for(j=0;j<80;j++) s[i][j]=EOF; } /* * Terminal dependant stuff (this is for a HP) */ clear() { printf("\033H\033J"); /* Clear screen HP262X */ /* printf("\033[H\033[J"); /* Clear screen VT100 */ } char *cursor(i,j) int i,j; { static char cs[12]; sprintf(cs,"\033&a%dy%dC",i,j); /* cursor HP262X */ /* sprintf(cs,"\033[%d;%dH",i,j); /* cursor VT100 */ return(cs); }