Ir ao conteúdo
  • Cadastre-se

registro

Membro Júnior
  • Posts

    3
  • Cadastrado em

  • Última visita

Reputação

1
  1. Bom Simon, vamos lá: * Quanto ao delay, estou ciente do atraso. O problema se resolve com o cálculo básico que o programa leva pra executar diferentes procedures e desse valor tirar e diferença pra que no mínimo fique mais próximo do "mundo real". Apenas uma análise minuciosa. * A execução dos comandos sem necessidade acontece mesmo, mas não apenas nos três últimos comandos. Na lógica feita, sempre pelos menos 3 comandos dentro do while executarão sem necessidade. Nos primeiros 60min. Um tratamento baseado na situação atual do cronometro em questão durante o processo do programa resolve (embora duplique e tenha mais linhas de códigos, pois já está feito nos procedures). while (s < 60) do begin sessentaSegundos; sessentaMinutos; apartirDeUmaHora; apartirDeDezHoras; end; * Nesse while há o seguinte controle: a cada 59s, o programa sai do while e printa o minuto/hora cravado/cavada em questão. Quando completar 1min cravado (s=60), sai do laço while e printa 00h:01m:00s no procedure printaAteUmaHoraCravada. Quando completar 1h cravada (s=60), sai do laço while e printa 01h:00m:00s no procedure printaAteUmaHoraCravada e assim por diante conforme a hora seja adicionada. De maneira que a cada 59s, o programa sai do laço while e printa o minuto ou hora cravada em questão em uns dos procedures fora while durante a execução do programa. * "Agora, em relação a lógica para calcular o tempo, eu sugiro de uma forma diferente... Você meio que está verificado a cada loop em qual se situação se encontra as casas... eu acho que poderia ser apenas contabilizando e adicionando ao segundo. Daí, ao completar 60, soma mais um no minuto... este tem uma verificação interna que se completar 60, soma um na hora... este ao completar 24 soma um ao dia... etc. Entendeu? O "evento de receber um é que exige o controle na casa"... o programa em execução precisa apenas se preocupa em "contabilizar um segundo (tempo), e somar um ao segundo (variável)"...." * Não consegui pegar a ideia acima. Pode explicar de outra forma!? O controle de segundos, minutos e horas estão sendo tratados normal a cada 60s. No aguardo.
  2. Acredito que talvez há outras formas de desenvolver, mas por enquanto fico com essa. Processa até 24h. Qualquer bugs/sugestão reportar por favor Program Cronometro_Crescente; var h,m,s: integer; procedure sessentaSegundos; begin if (h = 0) and (m = 0) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end else begin if (h = 0) and (m = 0) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:',s,'s'); delay(1000); s := s + 1; end; end; end; procedure sessentaMinutos; begin if (h = 0) and ((m >= 1) and (m < 10)) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if (h = 0) and ((m >= 1) and (m < 10)) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:',s,'s'); delay(1000); s := s + 1; end; if (h = 0) and ((m >= 10) and (m <= 59)) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if (h = 0) and ((m >= 10) and (m <= 59)) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:',m,'m:',s,'s'); delay(1000); s := s + 1; end; end; procedure apartirDeUmaHora; begin if ((h >= 1) and (h < 10)) and (m = 0) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if ((h >= 1) and (h < 10)) and (m = 0) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:',s,'s'); delay(1000); s := s + 1; end; if ((h >= 1) and (h < 10)) and ((m >= 1) and (m < 10)) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if ((h >= 1) and (h < 10)) and ((m >= 1) and (m < 10)) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:',s,'s'); delay(1000); s := s + 1; end; if ((h >= 1) and (h < 10)) and ((m >= 10) and (m <= 59)) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:',m,'m:0',s,'s'); {alterado} delay(1000); s := s + 1; end; if ((h >= 1) and (h < 10)) and ((m >= 10) and (m <= 59)) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:',m,'m:',s,'s'); delay(1000); s := s + 1; end; end; procedure apartirDeDezHoras; begin if ((h >= 10) and (h <= 23)) and (m = 0) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write(h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; {***} if ((h >= 10) and (h <= 23)) and (m = 0) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write(h,'h:0',m,'m:',s,'s'); {FIM} delay(1000); s := s + 1; end; if ((h >= 10) and (h <= 23)) and ((m >= 1) and (m < 10)) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write(h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if ((h >= 10) and (h <= 23)) and ((m >= 1) and (m < 10)) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write(h,'h:0',m,'m:',s,'s'); delay(1000); s := s + 1; end; if ((h >= 10) and (h <= 23)) and ((m >= 10) and (m <= 59)) and (s < 10) then begin clrscr; gotoxy(35,12); textcolor(red); write(h,'h:',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if ((h >= 10) and (h <= 23)) and ((m >= 10)) and (m <= 59) and (s >= 10) then begin clrscr; gotoxy(35,12); textcolor(red); write(h,'h:',m,'m:',s,'s'); delay(1000); s := s + 1; end; end; procedure printaAteUmaHoraCravada; begin if (h = 0) and (m = 0) and (s = 60) then begin s := 0; m := m + 1; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end else begin if (h = 0) and ((m >= 1) and (m <= 8)) and (s = 60) then begin s := 0; m := m + 1; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; end; if (h = 0) and ((m >= 9) and (m <= 58)) and (s = 60) then begin s := 0; m := m + 1; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if (h = 0) and (m = 59) and (s = 60) then begin h := 1; m := 0; s := 0; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; m := 0; end; {ateUmaHoraCravada} end; procedure printaAteNoveHorasCravada; begin if ((h >= 1) and (h < 10)) and (m = 0) and (s = 60) then begin s := 0; m := m + 1; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if ((h >= 1) and (h < 10)) and ((m >= 1) and (m <= 8)) and (s = 60) then begin s := 0; m := m + 1; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if ((h >= 1) and (h < 10)) and ((m >= 9) and (m <= 58)) and (s = 60) then begin s := 0; m := m + 1; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:',m,'m:0',s,'s'); {u.aqui} delay(1000); s := s + 1; end; if ((h >= 1) and (h <= 8)) and (m = 59) and (s = 60) then begin h := h + 1; s := 0; m := 0; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); {u.aqui 2} delay(1000); s := s + 1; end; end; procedure printaAcimaDeDezHorasCravada; begin if ((h >= 9) and (h <= 23)) and (m = 0) and (s = 60) then begin s := 0; m := m + 1; clrscr; gotoxy(35,12); textcolor(red); write(h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if ((h >= 9) and (h <= 23)) and ((m >= 1) and (m < 10)) and (s = 60) then begin s := 0; m := m + 1; clrscr; gotoxy(35,12); textcolor(red); write(h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; if ((h >= 9) and (h <= 23)) and ((m >= 10) and (m <= 58)) and (s = 60) then begin s := 0; m := 0; clrscr; gotoxy(35,12); textcolor(red); write(h,'h:0',m,'m:',s,'s'); delay(1000); s := s + 1; m := m + 1; end; if ((h >= 9) and (h <= 23)) and (m = 59) and (s = 60) then begin h := h + 1; s := 0; m := 0; clrscr; gotoxy(35,12); textcolor(red); write(h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; end; end; Begin h := 0; m := 0; s := 0; clrscr; gotoxy(35,12); textcolor(red); write('0',h,'h:0',m,'m:0',s,'s'); delay(1000); s := s + 1; repeat while (s < 60) do begin sessentaSegundos; sessentaMinutos; apartirDeUmaHora; apartirDeDezHoras; end; printaAteUmaHoraCravada; printaAteNoveHorasCravada; printaAcimaDeDezHorasCravada; until(h = 24); clrscr; gotoxy(30,12); textcolor(red); write('*** 24h DECORRIDAS ***'); End.
  3. Terceira versão simples do programinha de cronômetro crescente no formato hh:mm:ss que fiz em pascal. Vai de 00h:00m:00s a 24h:00m:00s Se houver erros, reportar por favor. Fiz todos os testes, mas nunca se sabe

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...