program scroll_text; uses crt; const SPC = ' '; var text : string; x,y,len,i : byte; start,fin : byte; begin textmode(80); randomize; textcolor(black); clrscr; textcolor(10); write('Please type in a sentence : '); textcolor(11); read(text); textcolor(black); clrscr; if text = '' then text := 'This is a small pascal program called Scroll_Text'; {49 chars} len := length(text); start := 1; fin := 1; x := 80; y := 13; repeat { gotoxy(x,y); write(SPC:len);} textcolor(9); gotoxy(x,y); for i := start to fin do write(text[i]); textcolor(black); gotoxy(1,25); delay(14); { try 7 } dec(x,1); if x > 1 then begin inc(fin,1); if fin = len then fin := len; end else if x < 1 then begin inc(start,1); x := 1; end; if start = len+2 then begin start := 1; fin := 1; x := 80; y := random(24)+1; end; until keypressed; textcolor(lightgray); clrscr; end.