Advertisement
Zung_the_great

Typing master demo (pascal !)

Mar 2nd, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. program Tap_danh_chu;
  2. uses
  3. {$IFDEF UNIX}{$IFDEF UseCThreads}
  4. cthreads,
  5. {$ENDIF}{$ENDIF}
  6. crt,dos
  7. { you can add units after this };
  8. type int = longint;
  9. {+N}
  10. var f : text;
  11. s : array[1..100] of string;
  12. n,ans : int;
  13. time : real;
  14. fault : int;
  15. start : longint;
  16. now : longint absolute 0:$46C;
  17.  
  18. procedure cover(color:int);
  19. var i,j:int;
  20. begin
  21. textcolor(color); textbackground(color);
  22. for I:=1 to 26 do for j:=1 to 80 do write('C');
  23. textcolor(green);
  24. end;
  25.  
  26. procedure writesl(s:string);
  27. var i:int;
  28. begin
  29. for i:=1 to length(s) do begin write(s[i]); delay(19); end;
  30. end;
  31.  
  32. procedure head;
  33. begin
  34. cover(7);
  35. textcolor(black);
  36. Gotoxy(35,12); writesl('TYPING MASTER'); delay(1000);
  37. gotoxy(1,25); writesl('CREATED by : '); textcolor(red);
  38. writesl('Coding to the sun'); delay(1000);
  39. textcolor(black);
  40.  
  41. gotoxy(1,1); writesl('Copy right Dos ''n'' Pascal inc'); delay(1000);
  42. repeat
  43. Gotoxy(67,25); writesl('Press any key'); delay(400);
  44. gotoxy(67,25); clreol;
  45. until keypressed;
  46. end;
  47. procedure ins;
  48. begin
  49. writeln('When you done the text, you should type space to end it ! ');
  50. writeln;
  51. writeln('The text apears only when you type the right wrords ');
  52. writeln;
  53. writeln('if you type the wrong words, you fail one score ');
  54. writeln;
  55. writeln('press enter');
  56. end;
  57.  
  58. procedure menu;
  59. begin
  60. clrscr;
  61. gotoxy(35,3); writesl('Beginner '); write('1');
  62. gotoxy(35,4); writesl('Easy '); write('2');
  63. gotoxy(35,5); writesl('Medium '); write('3');
  64. gotoxy(35,6); writesl('Expert '); write('4');
  65. gotoxy(35,7); writesl('Free text file '); write('5');
  66. gotoxy(35,8); writesl('INSTRUCTION ! '); write('6');
  67. gotoxy(1,24); write('YOU CHOSE : '); read(ans); clrscr;
  68. if ans=6 then begin ins; repeat until keypressed; menu; end;
  69.  
  70. end;
  71.  
  72. procedure typing;
  73. var inp :char;
  74. d,w,dem :int;
  75. x1,y1 :int;
  76. x,y,count:int;
  77. begin
  78. textcolor(black); d:=1 ; count:=0;
  79. w:=1;
  80. x:=1; y:=1; x1:=wherex; y1:=wherey; dem:=0;
  81. start:=now;
  82. textcolor(green);
  83. repeat
  84. inp:=readkey;
  85. if inp=#27 then begin clrscr; textcolor(red); write('you quit !!'); readln; exit; end;
  86. if (inp<> s[d][w])and(s[d][w]<>#13) then
  87. repeat
  88. inp:=readkey; inc(fault);
  89. until inp=s[d][w];
  90. write(inp);
  91. if inp<>' ' then inc(dem); inc(count);
  92. { }
  93. textcolor(red);
  94. gotoxy(x,y); write(s[d][w]); textcolor(green);
  95. inc(x,1); inc(x1,1); gotoxy(x1,y1); inc(w);
  96.  
  97. if x=80 then begin inc(y); x:=1; end;
  98. if x1=80 then begin inc(y1); x1:=1; end;
  99. { }
  100. if s[d][w+1]=#13 then begin x1:=0; inc(y1); inc(count); end;
  101. if (count=length(s[d])) then
  102. begin
  103. inc(d);
  104. w:=1; count:=1;
  105. end;
  106. textcolor(green);
  107. gotoxy(1,25); write(count,' ');write('words !'); gotoxy(x1,y1);
  108. textcolor(green);
  109. until (d=n+1);
  110. time:=(now-start)/58.62;
  111. writeln; textcolor(red);
  112. writeln('FAULT u got : ',fault);
  113. writeln('TIME running : ',time:0:0);
  114. readln;
  115. end;
  116.  
  117. procedure proces;
  118. var k:char; i:int;
  119. begin
  120. n:=1; fault:=0;
  121. case ans of
  122. 1: begin
  123. assign(f,'easy1.part'); reset(f);
  124. while not eof(f) do
  125. begin
  126. read(f,k);
  127. s[n]:=s[n]+k;
  128. if (length(s[n])>100) then inc(n);
  129. end;
  130. for i:=1 to n do write(s[n]); writeln;
  131. close(f);
  132. end;
  133. end;textcolor(red);
  134. for i:=1 to 38 do write('~'); textcolor(yellow);write('TYPE');
  135. textcolor(red); for i:=1 to 38 do write('~'); writeln;
  136. typing;
  137.  
  138. end;
  139.  
  140. begin
  141. clrscr;
  142. head; menu; ans:=1; proces; readln;
  143. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement