Advertisement
Guest User

pascal

a guest
Apr 6th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 5.88 KB | None | 0 0
  1. Program programa;
  2. uses crt;
  3. var op,op1,i,aux,colortext,colorback,h,m,s:integer;
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. procedure menu_(x,y,tamanho,cor_atual:integer);
  13. var i,a:integer;
  14. begin
  15. textcolor(4);
  16. gotoxy(x,y);
  17. for i:=1 to tamanho do
  18.     write('#');
  19.  
  20.  
  21. for i:=1 to (tamanho-22) do
  22. begin
  23.     gotoxy(x,y+i);
  24.     write('#');
  25.     gotoxy(x+tamanho-1,y+i);
  26.     writeln('#');
  27. end;
  28. gotoxy(x,tamanho+1-22);
  29. for i:=1 to tamanho do
  30.     write('#');
  31.  
  32. textcolor(cor_atual)
  33.  
  34. end;
  35.  
  36.  
  37.  
  38.  
  39.  
  40.     Procedure menu(op,x,y,cor_atual:integer);           //op-> 0=menu principal     1=menu de funçoes
  41.     begin
  42.                                     //procedimento que escreve menu no ecra
  43.         case op of
  44.             0:begin
  45.                 menu_(20,1,31,cor_atual);
  46.                 gotoxy(x+8,y);
  47.                 writeln('---MENU---');
  48.                 gotoxy(x,y+2);
  49.                 writeln('1- Opções de Visualização');
  50.                 gotoxy(x,y+3);
  51.                 writeln('2- Temporizador');
  52.                 gotoxy(x,y+4);
  53.                 writeln('3- Cronómetro');
  54.                 gotoxy(x,y+5);
  55.                 writeln('0- Sair');
  56.  
  57.                 writeln;
  58.             end;
  59.  
  60.             1:begin
  61.                 menu_(20,1,31,cor_atual);
  62.                 gotoxy(x+8,y);
  63.                 writeln('---MENU---');
  64.                 gotoxy(x,y+2);
  65.                 writeln('1- Cor de texto');
  66.                 gotoxy(x,y+3);
  67.                 writeln('2- Cor de fundo');
  68.                 gotoxy(x,y+4);
  69.                 writeln('3- Efeitos de cores');
  70.                 gotoxy(x,y+5);
  71.                 writeln('0- Anterior');
  72.                 writeln;
  73.             end;
  74.         end;
  75.  
  76.  
  77.     end;
  78.  
  79.  
  80.  
  81.     //PROCEDIMENTOS QUE ALTERAM A COR //
  82. {
  83. 0->Preto
  84. 1->Azul
  85. 2->Verde
  86. 3->Azul-marinho
  87. 4->Vermelho
  88. 5->Laranja
  89. 6->Marrom
  90. 7->Cinza-claro
  91. 8->Cinza-escuro}
  92.  
  93.  
  94. Procedure cod_cores;
  95. begin
  96.     writeln('-------------------Código de Cores-------------------');
  97.     writeln('0->Preto');
  98.     writeln('1->Azul');
  99.     writeln('2->Verde');
  100.     writeln('3->Azul-marinho');
  101.     writeln('4->Vermelho');
  102.     writeln('5->Laranja');
  103.     writeln('6->Marrom ');
  104.     writeln('7->Cinza-claro ');
  105.     writeln('8->Cinza-escuro');
  106.  
  107. end;
  108.  
  109.  
  110.  
  111.  
  112. Procedure cor_fundo(var cor:integer);
  113. var i:integer;
  114. begin
  115.  
  116.     for i:=1 to 1990 do
  117.     begin
  118.     textbackground(cor);
  119.     write(' ');
  120.     end;
  121. end;
  122.  
  123.  
  124.  
  125. //FIM DOS PROCEDIMENTOS//
  126.  
  127.  
  128.  
  129.  
  130. Procedure temporizador(horas,minutos,segundos:integer);
  131. var h,m,s:integer;ini,ent:boolean;
  132. begin
  133. ini:=false;
  134. ent:=false;
  135. writeln('Para parar pressione qualquer tecla');
  136. for h:=horas downto 0 do
  137.     begin
  138.         if (minutos<59) and (not ent) then
  139.         begin
  140.         ent:=true;
  141.             for m:=minutos downto 0 do
  142.                 begin
  143.                     if (segundos<59) and (not ini) then
  144.                         begin
  145.                             ini:=true;
  146.                             for s:=segundos downto 0 do
  147.                                 begin
  148.                                 write(h,':',m,':',s);
  149.                                     delay(1000);
  150.                                     clrscr;
  151.                                     writeln('Para parar pressione qualquer tecla');
  152.                                     if keypressed then
  153.                                     exit;
  154.  
  155.  
  156.                                 end;
  157.                         end
  158.                             else
  159.                             begin
  160.                                 for s:=59 downto 0 do
  161.                                 begin
  162.  
  163.                                     write(h,':',m,':',s);
  164.                                     delay(1000);
  165.                                     clrscr;
  166.                                     writeln('Para parar pressione qualquer tecla');
  167.                                     if keypressed then
  168.                                     exit;
  169.  
  170.                                 end;
  171.  
  172.  
  173.                             end;
  174.  
  175.  
  176.                 end;
  177.  
  178.         end
  179.             else
  180.  
  181.             begin
  182.  
  183.             for m:=59 downto 0 do
  184.                 begin
  185.                 ent:=true;
  186.                     if (segundos<59) and (not ini) then
  187.                         begin
  188.                             ini:=true;
  189.                             for s:=segundos downto 0 do
  190.                                 begin
  191.                                     write(h,':',m,':',s);
  192.                                     delay(1000);
  193.                                     clrscr;
  194.                                     writeln('Para parar pressione qualquer tecla');
  195.                                     if keypressed then
  196.                                     exit;
  197.  
  198.                                 end;
  199.                         end
  200.                             else
  201.                             begin
  202.                                 for s:=59 downto 0 do
  203.                                 begin
  204.                                     write(h,':',m,':',s);
  205.                                     delay(1000);
  206.                                     clrscr;
  207.                                     writeln('Para parar pressione qualquer tecla');
  208.                                     if keypressed then
  209.                                     exit;
  210.                                 end;
  211.  
  212.             end;
  213.             end;
  214.             end;
  215.  
  216.     end;
  217.  
  218. end;
  219.  
  220.  
  221.  
  222. Procedure cronometro;
  223. var h,m,s:integer;
  224. begin
  225. writeln('Para parar pressione qualquer tecla');
  226. for h:=0 to 24 do
  227.     for m:=0 to 59 do
  228.         for s:=0 to 59 do
  229.         begin
  230.             writeln(h,':',m,':',s);
  231.             delay(1000);
  232.             clrscr;
  233.             writeln('Para parar pressione qualquer tecla');
  234.             if keypressed then
  235.             exit;
  236.         end;
  237.  
  238. end;
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253. Procedure muda_cores;
  254. var tipo:integer;
  255. begin
  256.  
  257.         while not keypressed do
  258.         begin
  259.         randomize;
  260.             tipo:=random(3)+1;
  261.             textbackground(random(8)+1);
  262.  
  263.                 case tipo of
  264.  
  265.                     1:
  266.                     for i:=1 to 4 do
  267.                         begin
  268.                         clrscr;
  269.                         textbackground(random(8)+1);
  270.                         delay(70);
  271.                         end;
  272.  
  273.  
  274.                     2:
  275.                     for i:=1 to 700 do
  276.                         begin
  277.                         write(' ');
  278.                         textbackground(random(8)+1);
  279.                         delay(3);
  280.                         end;
  281.  
  282.                     3:
  283.                             for i:=1 to  700 do
  284.                         begin
  285.                         write(' ');
  286.                         delay(3);
  287.                         end;
  288.  
  289.  
  290.                 end;
  291.  
  292.         END;
  293. end;
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.                 //PROGRAMA PRINCIPAL//
  301.  
  302. begin
  303.  
  304.  
  305.     gotoxy(1,1);
  306.     colortext:=7;
  307.     colorback:=1;
  308.  
  309.     repeat
  310.     cor_fundo(colorback);
  311.     textcolor(colortext);  
  312.     menu(0,23,2,colortext);
  313.     gotoxy(23,9);
  314.     write('Digite a opção-> ');
  315.     read(op);
  316.  
  317.  
  318.         case op of
  319.  
  320.             1:begin
  321.                 Repeat
  322.                     clrscr;
  323.                     menu(1,23,2,colortext);
  324.                     gotoxy(23,9);
  325.                     write('Digite a opção-> ');
  326.                     read(op1);
  327.                     case op1 of
  328.  
  329.                         1:begin
  330.                             clrscr;
  331.                             cod_cores;
  332.                             writeln;
  333.                             writeln('Insira o valor da cor a alterar-> ');
  334.                             readln(colortext);
  335.                             textcolor(colortext);
  336.  
  337.                         end;
  338.  
  339.                         2:begin
  340.                             clrscr;
  341.                             cod_cores;
  342.                             writeln;
  343.                             writeln('Insira o valor da cor a alterar-> ');
  344.                             read(colorback);
  345.                             cor_fundo(colorback);
  346.                             gotoxy(1,1);
  347.  
  348.                         end;
  349.  
  350.  
  351.                     3:begin
  352.                         clrscr;
  353.                         muda_cores;
  354.                         textbackground(colorback);
  355.                     end;
  356.  
  357.  
  358.  
  359.                     end;
  360.  
  361.  
  362.  
  363.                 Until op1=0;
  364.  
  365.             end;
  366.  
  367.  
  368.             2:begin
  369.                 writeln('Insira as horas: ');
  370.                 readln(h);
  371.                 writeln('Insira os minutos: ');
  372.                 readln(m);
  373.                 writeln('Insira os segundos: ');
  374.                 readln(s);
  375.                 clrscr;
  376.                 temporizador(h,m,s);
  377.  
  378.             end;
  379.  
  380.  
  381.             3:  begin
  382.                 clrscr;
  383.                 cronometro;
  384.                 writeln;
  385.                 writeln('Para parar pressione qualquer tecla');
  386.             end;
  387.  
  388.  
  389.  
  390.  
  391.  
  392.         end;
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.         clrscr;
  400.  
  401.     until op=0;
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement