Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Pascal - Problemi con if
Forum - Pascal - Problemi con if

Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 1:00
Giovedì, 01/01/1970
Codice sorgente - presumibilmente Delphi

  1. program menu;
  2.  
  3. uses crt;
  4.  
  5. var
  6.         tasto:char;
  7.         flag:boolean;
  8.         cont:integer;
  9.  
  10.  
  11. begin
  12. cont:=0;
  13. flag:=false;
  14. repeat
  15.         clrscr;
  16.         textbackground(white);
  17.         textcolor(black);
  18.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  19.         gotoxy(30,15); writeln('Ascoltare musica');
  20.         gotoxy(30,17); writeln('Registrare musica');
  21.         gotoxy(30,19); writeln('Uscire');
  22.  
  23. repeat
  24. tasto:=readkey;
  25. until (tasto=#80) or (tasto=#72);
  26.  
  27. if (tasto=#80) then cont:=cont+1;
  28. if (tasto=#72) then cont:=cont-1;
  29. if cont=4 then cont:=1;
  30. if cont=-1 then cont:=3;
  31.  
  32. case cont of
  33. 1:      begin
  34.         clrscr;
  35.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  36.         textcolor(red);
  37.         gotoxy(30,15); writeln('Ascoltare musica');
  38.         gotoxy(30,17); writeln('Registrare musica');
  39.         gotoxy(30,19); writeln('Uscire');
  40.         end;
  41.  
  42. 2:      begin
  43.         clrscr;
  44.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  45.         gotoxy(30,15); writeln('Ascoltare musica');
  46.         textcolor(red);
  47.         gotoxy(30,17); writeln('Registrare musica');
  48.         textcolor(black);
  49.         gotoxy(30,19); writeln('Uscire');
  50.         end;
  51.  
  52. 3:      begin
  53.         clrscr;
  54.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  55.         gotoxy(30,15); writeln('Ascoltare musica');
  56.         gotoxy(30,17); writeln('Registrare musica');
  57.         textcolor(red);
  58.         gotoxy(30,19); writeln('Uscire');
  59.         flag:=true;
  60.         end;
  61. end;
  62.  
  63. until flag;
  64. end.



avevo già postato..ma adesso ho modificato perchè ho risolto da solo..qualcuno mi sa spiegare perchè si vede il colore solo con l'ultima opzione?! :pat:

Ultima modifica effettuata da il 07/03/2010 alle 0:59
PM Quote
Avatar
Poggi Marco (Member)
Guru


Messaggi: 969
Iscritto: 05/01/2010

Segnala al moderatore
Postato alle 10:57
Domenica, 07/03/2010
Ciao.
Ho letto il programma, e mon ho capito bene cosa deve fare.

Comuncue l' errore è dovuto al fatto imposti count in maniera errata.
Puoi usare direttamente tasto nei case, ed eventualmente specificare il tasto da premere nei menu'.

Un altro errore e quello di riscrivere il menù all' inizio del ciclo repeat.
In questo modo cancelli quello che scrivi nei case.

Come mai con P aumenti count, mentre con H lo diminuisci?

Ultima modifica effettuata da Poggi Marco il 07/03/2010 alle 12:00
PM Quote
Avatar
XBarboX (Member)
Guru


Messaggi: 945
Iscritto: 31/12/2008

Segnala al moderatore
Postato alle 15:19
Domenica, 07/03/2010
Testo quotato

Postato originariamente da Poggi Marco:
Comuncue


:om:

Ultima modifica effettuata da XBarboX il 07/03/2010 alle 15:20
PM Quote
Avatar
Poggi Marco (Member)
Guru


Messaggi: 969
Iscritto: 05/01/2010

Segnala al moderatore
Postato alle 16:03
Domenica, 07/03/2010
Testo quotato

Postato originariamente da XBarboX:

Testo quotato

Postato originariamente da Poggi Marco:
Comuncue


:om:




Opss...8-|

Chiedo scusa!

PM Quote
Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 21:30
Domenica, 07/03/2010
Sono tornato proprio ora da una giornati in un agriturismo e ho terminato il programma :)

purtroppo sul mio pc la funzione sound non va :( se qualcuno mi fa la cortesia di compilarlo e farmi sapere se funge o meno gliene sarei grato :)

Codice sorgente - presumibilmente Delphi

  1. program riproduttore_multimediale;
  2.  
  3.  
  4. uses crt;
  5.  
  6. var
  7.         tasto:char;
  8.         flag:boolean;
  9.         cont:integer;
  10.  
  11. {Procedura per riprodurre il suono}
  12. procedure riproduci_suono(input:integer);
  13. var
  14.         intensita,durata:integer;
  15. begin
  16. intensita:=input mod 1000;
  17. durata:=input-intensita;
  18. sound(intensita);
  19. delay(durata);
  20. nosound;
  21. end;
  22.  
  23. {Procedura per registrare il suono}
  24. procedure registra;
  25. var
  26.         lunghezza,frequenza,codificato:integer;
  27.         percorso:string[30];
  28.         nota:string[3];
  29.         uscita:boolean;
  30.         file_output:textfile;
  31.         tasto:char;
  32.  
  33. begin
  34. CLRSCR;
  35. uscita:=false;
  36.  
  37. write('Percorso in cui salvare il file audio : '); readln(percorso);
  38.         assign(file_output,percorso);
  39.         rewrite(file_output);
  40. repeat
  41. repeat
  42.         clrscr;
  43.         textcolor(black);
  44.         gotoxy(1,1);
  45.         writeln('Premi ESC per uscire (uscirà dopo aver digitato la nota da salvare)');
  46.         gotoxy(20,6);
  47.         write('Nota (DO/RE/MI/FA/SOL/LA/SI) : ');
  48.         tasto:=readkey;
  49.         if tasto=#27 then uscita:=true;
  50.                 textcolor(red);
  51.                 readln(nota);
  52.  
  53. until (nota='DO') or (nota='RE') or (nota='MI') or (nota='FA') or (nota='SOL') or (nota='LA') or (nota='SI') or uscita;
  54.         textcolor(black);
  55.         write('Durata (in secondi) : '); readln(lunghezza);
  56.  
  57.  
  58.  
  59. if nota='DO' then frequenza:=262
  60. else if nota='RE' then frequenza:=294
  61. else if nota='MI' then frequenza:=330
  62. else if nota='FA' then frequenza:=349
  63. else if nota='SOL' then frequenza:=392
  64. else if nota='LA' then frequenza:=440
  65. else if nota='SI' then frequenza:=494;
  66.  
  67.  
  68.         codificato:=frequenza+lunghezza*1000;
  69.         append(file_output);
  70.         write(file_output,codificato);
  71.         write(file_output,' ');
  72.         close(file_output);
  73.  
  74. until uscita;
  75.  
  76. end;
  77.  
  78.  
  79. {procedura per la riproduzione}
  80. procedure riproduzione;
  81.  
  82. type contenitore=array[1..255] of integer;
  83.  
  84. var
  85.         i,b:integer;
  86.         letto:contenitore;
  87.         percorso:string[30];
  88.         file_input:textfile;
  89.  
  90. begin
  91. write('Percorso file da riprodurre : '); readln(percorso);
  92. assign(file_input,percorso);
  93. reset(file_input);
  94.  
  95. i:=1;
  96. while not eof(file_input) do
  97. begin
  98.   read(file_input, letto[i]);
  99.   i:=i+1;
  100. end;
  101.  
  102. b:=i;
  103. i:=1;
  104.  
  105. for i:=1 to b do
  106. begin
  107. riproduci_suono(letto[i]);
  108. end;
  109.  
  110. end;
  111.  
  112.  
  113.  
  114.  
  115. {Programma}
  116. begin
  117. cont:=0;
  118. flag:=false;
  119.  
  120.         clrscr;
  121.         textbackground(white);
  122.         textcolor(white);
  123.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  124.         gotoxy(30,15); writeln('Ascoltare musica');
  125.         gotoxy(30,17); writeln('Registrare musica');
  126.         gotoxy(30,19); writeln('Uscire');
  127.  
  128. repeat
  129. repeat
  130. tasto:=readkey;
  131. until (tasto=#80) or (tasto=#72);
  132.  
  133. if (tasto=#80) then begin tasto:=' '; cont:=cont+1 end;
  134. if (tasto=#72) then begin tasto:=' '; cont:=cont-1 end;
  135. if cont=4 then cont:=1;
  136. if cont=-1 then cont:=3;
  137.  
  138. case cont of
  139. 1:      begin
  140.         clrscr;
  141.         textcolor(white);
  142.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  143.         textcolor(red);
  144.         gotoxy(30,15); writeln('Ascoltare musica');
  145.         textcolor(white);
  146.         gotoxy(30,17); writeln('Registrare musica');
  147.         gotoxy(30,19); writeln('Uscire');
  148.         repeat
  149.         begin
  150.         tasto:=readkey;
  151.         if tasto=#13 then riproduzione;
  152.         end;
  153.         until (tasto=#13) or (tasto=#80) or (tasto=#72);
  154.  
  155.         end;
  156.  
  157. 2:      begin
  158.         clrscr;
  159.         textcolor(white);
  160.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  161.         gotoxy(30,15); writeln('Ascoltare musica');
  162.         textcolor(red);
  163.         gotoxy(30,17); writeln('Registrare musica');
  164.         textcolor(white);
  165.         gotoxy(30,19); writeln('Uscire');
  166.         repeat
  167.         begin
  168.         tasto:=readkey;
  169.         if tasto=#13 then registra;
  170.         end;
  171.         until (tasto=#13) or (tasto=#80) or (tasto=#72) or (tasto=#27);
  172.         end;
  173.  
  174. 3:      begin
  175.         clrscr;
  176.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  177.         gotoxy(30,15); writeln('Ascoltare musica');
  178.         gotoxy(30,17); writeln('Registrare musica');
  179.         textcolor(red);
  180.         gotoxy(30,19); writeln('Uscire');
  181.         repeat
  182.         begin
  183.                 tasto:=readkey;
  184.                 if tasto=#13 then
  185.                         begin
  186.                         writeln('Bye bye :D'); delay(3000);    
  187.                         flag:=true
  188.                         end;
  189.         end;
  190.         until (tasto=#13) or (tasto=#80) or (tasto=#72);
  191.         end;
  192. end;
  193.  
  194. until flag;
  195. end.



errori/consigli/migliorie sono ben accetti (sono un principiante ancora:rofl:) :D

PM Quote
Avatar
Poggi Marco (Member)
Guru


Messaggi: 969
Iscritto: 05/01/2010

Segnala al moderatore
Postato alle 22:11
Domenica, 07/03/2010
Ho letto il programma, e la scelta del menu è ancore molto macchinosa.
Potresti accedere alle varie funzioni del programma, confrontando semplicemente la veriabile tasto.

La funzione di registrazione, è alquanto confusa.
La chiusura del file, avviene all' interno del ciclo repeat. In questo modo verra salvata solo la prima nota. Il mio consiglio è quello di salvare il valore "codificato" e "lunghezza" separatamente per ogni nota.
L' istruzione " write(file_output,' '); " è inutile e ti darà problemi in lettura. Infatti il comando write separa automaticamente i dati scritti su file.


Nella funzione procedure "riproduci_suono(input:integer); " usi il comando delay.
Purtroppo, esso si affida ai clok della cpu, quindi non è affidabile.
Sei costratto a programmarti una funzione apposita.









Ultima modifica effettuata da Poggi Marco il 07/03/2010 alle 22:27
PM Quote
Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 0:12
Lunedì, 08/03/2010
Per il menù cercherò di provvedere domani, anch'io mi sono reso conto che è abbastanza macchinoso..ma ho letto robe che, a mio avviso, sono peggiori..

la funzione di registrazione è l'unica cosa che al momento (almeno sul mio pc) funge :D salva tutto. la mia idea è quella di salvare la frequenza della nota e la sua durata in un unico numero chiamato codificato che poi appunto verra decodificato e riportato ad essere 2 numeri separati..

ciò che al momento mi da fastidio è la difficoltà nell'uscita dalle funzioni del programma..una volta terminata una determinata funzione vi è per forza il bisogno di premere freccia in giù o freccia in su per tornare al menù principale..però la cosa che mi interesserebbe maggiormente è sapere se si sente qualcosa..

PM Quote
Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 14:16
Lunedì, 08/03/2010
Codice sorgente - presumibilmente Delphi

  1. program riproduttore_multimediale;
  2.  
  3.  
  4. uses crt;
  5.  
  6. var flag,stop:boolean;
  7.  
  8. {Procedura per riprodurre il suono}
  9. procedure riproduci_suono(input:integer);
  10. var
  11.         intensita,durata:integer;
  12. begin
  13. intensita:=input mod 1000;
  14. durata:=input-intensita;
  15. sound(intensita);
  16. delay(durata);
  17. nosound;
  18. end;
  19.  
  20. {Procedura per registrare il suono}
  21. procedure registra;
  22. var
  23.         lunghezza,frequenza,codificato:integer;
  24.         percorso:string[30];
  25.         nota:string[3];
  26.         uscita:boolean;
  27.         file_output:textfile;
  28.         tasto:char;
  29.  
  30. begin
  31. CLRSCR;
  32. uscita:=false;
  33.  
  34. write('Percorso in cui salvare il file audio : '); readln(percorso);
  35.         assign(file_output,percorso);
  36.         rewrite(file_output);
  37. repeat
  38. repeat
  39.         clrscr;
  40.         textcolor(black);
  41.         gotoxy(1,1);
  42.         writeln('Premi ESC per uscire (uscirà dopo aver digitato la nota da salvare)');
  43.         gotoxy(20,6);
  44.         write('Nota (DO/RE/MI/FA/SOL/LA/SI) : ');
  45.         tasto:=readkey;
  46.         if tasto=#27 then uscita:=true;
  47.                 textcolor(red);
  48.                 readln(nota);
  49.  
  50. until (nota='DO') or (nota='RE') or (nota='MI') or (nota='FA') or (nota='SOL') or (nota='LA') or (nota='SI') or uscita;
  51.         textcolor(black);
  52.         write('Durata (in secondi) : '); readln(lunghezza);
  53.  
  54.  
  55.  
  56. if nota='DO' then frequenza:=262
  57. else if nota='RE' then frequenza:=294
  58. else if nota='MI' then frequenza:=330
  59. else if nota='FA' then frequenza:=349
  60. else if nota='SOL' then frequenza:=392
  61. else if nota='LA' then frequenza:=440
  62. else if nota='SI' then frequenza:=494;
  63.  
  64.  
  65.         codificato:=frequenza+lunghezza*1000;
  66.         append(file_output);
  67.         write(file_output,codificato);
  68.         write(file_output,' ');
  69.         close(file_output);
  70.  
  71. until uscita;
  72.  
  73. end;
  74.  
  75.  
  76. {procedura per la riproduzione}
  77. procedure riproduzione;
  78.  
  79. type contenitore=array[1..255] of integer;
  80.  
  81. var
  82.         i,b:integer;
  83.         letto:contenitore;
  84.         percorso:string[30];
  85.         file_input:textfile;
  86.  
  87. begin
  88. write('Percorso file da riprodurre : '); readln(percorso);
  89. assign(file_input,percorso);
  90. reset(file_input);
  91.  
  92. i:=1;
  93. while not eof(file_input) do
  94. begin
  95.   read(file_input, letto[i]);
  96.   i:=i+1;
  97. end;
  98.  
  99. b:=i;
  100. i:=1;
  101.  
  102. for i:=1 to b do
  103. begin
  104. riproduci_suono(letto[i]);
  105. end;
  106.  
  107. end;
  108.  
  109. {Menu}
  110. procedure menu;
  111.  
  112.  
  113. var
  114.         tasto:char;
  115.         move:boolean;
  116.         cont:integer;
  117.  
  118.  
  119. begin
  120. cont:=0;
  121. flag:=false;
  122. move:=false;
  123.  
  124.         clrscr;
  125.         textbackground(white);
  126.         textcolor(white);
  127.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  128.         gotoxy(30,15); writeln('Ascoltare musica');
  129.         gotoxy(30,17); writeln('Registrare musica');
  130.         gotoxy(30,19); writeln('Uscire');
  131.  
  132. repeat
  133.  
  134. stop:=false;
  135.  
  136. if move=false then
  137. begin
  138. repeat
  139. tasto:=readkey;
  140. until (tasto=#80) or (tasto=#72);
  141. if (tasto=#80) then begin tasto:=' '; cont:=cont+1 end;
  142. if (tasto=#72) then begin tasto:=' '; cont:=cont-1 end;
  143. end;
  144.  
  145. if cont=4 then cont:=1;
  146. if cont=-1 then cont:=3;
  147. move:=false;
  148.  
  149. case cont of
  150. 1:      begin
  151.         clrscr;
  152.         textcolor(white);
  153.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  154.         textcolor(red);
  155.         gotoxy(30,15); writeln('Ascoltare musica');
  156.         textcolor(white);
  157.         gotoxy(30,17); writeln('Registrare musica');
  158.         gotoxy(30,19); writeln('Uscire');
  159.         repeat
  160.         begin
  161.         tasto:=readkey;
  162.         if tasto=#13 then
  163.         begin
  164.         riproduzione;
  165.         stop:=true
  166.         end;
  167.         if tasto=#80 then begin cont:=cont+1; move:=true end;
  168.         if tasto=#72 then begin cont:=cont-1; move:=true end;
  169.         end;
  170.         until (tasto=#13) or (tasto=#80) or (tasto=#72) or stop;
  171.  
  172.         end;
  173.  
  174. 2:      begin
  175.         clrscr;
  176.         textcolor(white);
  177.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  178.         gotoxy(30,15); writeln('Ascoltare musica');
  179.         textcolor(red);
  180.         gotoxy(30,17); writeln('Registrare musica');
  181.         textcolor(white);
  182.         gotoxy(30,19); writeln('Uscire');
  183.         repeat
  184.         begin
  185.         tasto:=readkey;
  186.         if tasto=#13 then begin
  187.         registra;
  188.         stop:=true
  189.         end;
  190.         if tasto=#80 then begin cont:=cont+1; move:=true end;
  191.         if tasto=#72 then begin cont:=cont-1; move:=true end;
  192.         end;
  193.         until (tasto=#13) or (tasto=#80) or (tasto=#72) or stop;
  194.         end;
  195.  
  196. 3:      begin
  197.         clrscr;
  198.         gotoxy(1,1); writeln('Cosa vuoi fare?');
  199.         gotoxy(30,15); writeln('Ascoltare musica');
  200.         gotoxy(30,17); writeln('Registrare musica');
  201.         textcolor(red);
  202.         gotoxy(30,19); writeln('Uscire');
  203.         repeat
  204.         begin
  205.                 tasto:=readkey;
  206.                 if tasto=#13 then
  207.                         begin
  208.                         writeln('Bye bye :D'); delay(3000);    
  209.                         flag:=true
  210.                         end;
  211.                 if tasto=#80 then begin cont:=cont+1; move:=true end;
  212.                 if tasto=#72 then begin cont:=cont-1; move:=true end;
  213.         end;
  214.         until (tasto=#13) or (tasto=#80) or (tasto=#72);
  215.         end;
  216. end;
  217.  
  218. until flag OR stop;
  219. end;
  220.  
  221.  
  222.  
  223. {Programma}
  224. begin
  225.  
  226. repeat
  227. menu
  228. until flag;
  229.  
  230. end.



So che è mostruosamente brutto il menu, ma vorrei saperer se qualcuno sente l'audio. Se qualcuno mi vuole aiutare per favore provi a registrare qualcosa prima e poi provi a riprodurre.

PM Quote
Avatar
Poggi Marco (Member)
Guru


Messaggi: 969
Iscritto: 05/01/2010

Segnala al moderatore
Postato alle 22:33
Lunedì, 08/03/2010
Scusa Giarados, sono stato troppo critico, e non ho capito subito il metodo di registrazione del suono.

Ho provato il tuo programma e stranamente con Dev Pascal non funziona, mentre con il Turbo Pascal 7.0 funziona.

Ovviamente delay non è affidabile, ma ho creato una funzione per le pause a tempo.

Ecco il programma:

Codice sorgente - presumibilmente Delphi

  1. program riproduttore_multimediale;
  2. uses crt, dos;
  3. type textfile=text;
  4.  
  5. var flag,stop:boolean;
  6.  
  7. function tempo(var giorno:word):real;
  8. var h,m,s,s100:word;
  9.     anno, mese, GiornoDellaSettimana:word;
  10. begin
  11.  GetTime(h, m, s, s100);
  12.  GetDate(anno, mese, giorno, GiornoDellaSettimana);
  13.  tempo:=(h + 0.0)*3600 + 60*m + s + s100/100;
  14. end;
  15.  
  16. procedure pausa(t:real);
  17. var t0,te:real;
  18.     g,g0:word;
  19. begin
  20.  t0:=tempo(g0);
  21.  repeat
  22.   te:=tempo(g);
  23.   if g<>g0 then te:=te+86400;
  24.  until (te-t0)>t;
  25. end;
  26.  
  27. {Procedura per riprodurre il suono}
  28. procedure riproduci_suono(input:longint);
  29. var
  30.     intensita,durata:longint;
  31. begin
  32. intensita:=input mod 1000;
  33. durata:=input-intensita;
  34. sound(intensita);
  35. pausa(durata / 1000);
  36. nosound;
  37. end;
  38.  
  39. {Procedura per registrare il suono}
  40. procedure registra;
  41. var
  42.     lunghezza,frequenza,codificato:integer;
  43.     percorso:string[30];
  44.     nota:string[3];
  45.     uscita:boolean;
  46.     file_output:textfile;
  47.     tasto:char;
  48.  
  49. begin
  50. CLRSCR;
  51. uscita:=false;
  52.  
  53. write('Percorso in cui salvare il file audio : '); readln(percorso);
  54.     assign(file_output,percorso);
  55.     rewrite(file_output);
  56. repeat
  57. repeat
  58.     clrscr;
  59.     textcolor(black);
  60.     gotoxy(1,1);
  61.     writeln('Premi ESC per uscire (uscirà dopo aver digitato la nota da salvare)');
  62.     gotoxy(20,6);
  63.     write('Nota (DO/RE/MI/FA/SOL/LA/SI) : ');
  64.     tasto:=readkey;
  65.     if tasto=#27 then uscita:=true;
  66.         textcolor(red);
  67.         readln(nota);
  68.  
  69. until (nota='DO') or (nota='RE') or (nota='MI') or (nota='FA') or (nota='SOL') or (nota='LA') or (nota='SI') or uscita;
  70.     textcolor(black);
  71.     write('Durata (in secondi) : '); readln(lunghezza);
  72.  
  73.  
  74.  
  75. if nota='DO' then frequenza:=262
  76. else if nota='RE' then frequenza:=294
  77. else if nota='MI' then frequenza:=330
  78. else if nota='FA' then frequenza:=349
  79. else if nota='SOL' then frequenza:=392
  80. else if nota='LA' then frequenza:=440
  81. else if nota='SI' then frequenza:=494;
  82.  
  83.  
  84.     codificato:=frequenza+lunghezza*1000;
  85.     append(file_output);
  86.     write(file_output,codificato);
  87.     write(file_output,' ');
  88.  
  89. until uscita;
  90.  
  91.  close(file_output); (* Ho spostato il comando close fuori dal ciclo *)
  92. end;
  93.  
  94.  
  95. {procedura per la riproduzione}
  96. procedure riproduzione;
  97.  
  98. var
  99.     c:longint;
  100.     percorso:string[80];
  101.     file_input:textfile;
  102.  
  103. begin
  104. write('Percorso file da riprodurre : '); readln(percorso);
  105. assign(file_input,percorso);
  106. reset(file_input);
  107.  
  108. while not eof(file_input) do
  109. begin
  110.   read(file_input, c);
  111.   riproduci_suono(c); (* non salvo più i dati su un' array, ma *)
  112.                       (* li passo direttamente alla funzione   *)
  113. end;                  (* riproduci_suono                       *)
  114.  
  115. close(file_input);
  116.  
  117. end;
  118.  
  119. {Menu}
  120. procedure menu;
  121.  
  122.  
  123. var
  124.     tasto:char;
  125.     move:boolean;
  126.     cont:integer;
  127.  
  128.  
  129. begin
  130. cont:=0;
  131. flag:=false;
  132. move:=false;
  133.  
  134.     clrscr;
  135.     textbackground(white);
  136.     textcolor(white);
  137.     gotoxy(1,1); writeln('Cosa vuoi fare?');
  138.     gotoxy(30,15); writeln('Ascoltare musica');
  139.     gotoxy(30,17); writeln('Registrare musica');
  140.     gotoxy(30,19); writeln('Uscire');
  141.  
  142. repeat
  143.  
  144. stop:=false;
  145.  
  146. if move=false then
  147. begin
  148. repeat
  149. tasto:=readkey;
  150. until (tasto=#80) or (tasto=#72);
  151. if (tasto=#80) then begin tasto:=' '; cont:=cont+1 end;
  152. if (tasto=#72) then begin tasto:=' '; cont:=cont-1 end;
  153. end;
  154.  
  155. if cont=4 then cont:=1;
  156. if cont=-1 then cont:=3;
  157. move:=false;
  158.  
  159. case cont of
  160. 1:    begin
  161.     clrscr;
  162.     textcolor(white);
  163.     gotoxy(1,1); writeln('Cosa vuoi fare?');
  164.     textcolor(red);
  165.     gotoxy(30,15); writeln('Ascoltare musica');
  166.     textcolor(white);
  167.     gotoxy(30,17); writeln('Registrare musica');
  168.     gotoxy(30,19); writeln('Uscire');
  169.     repeat
  170.     begin
  171.     tasto:=readkey;
  172.     if tasto=#13 then
  173.     begin
  174.     riproduzione;
  175.     stop:=true
  176.     end;
  177.     if tasto=#80 then begin cont:=cont+1; move:=true end;
  178.     if tasto=#72 then begin cont:=cont-1; move:=true end;
  179.     end;
  180.     until (tasto=#13) or (tasto=#80) or (tasto=#72) or stop;
  181.  
  182.     end;
  183.  
  184. 2:    begin
  185.     clrscr;
  186.     textcolor(white);
  187.     gotoxy(1,1); writeln('Cosa vuoi fare?');
  188.     gotoxy(30,15); writeln('Ascoltare musica ');
  189.     textcolor(red);
  190.     gotoxy(30,17); writeln('Registrare musica');
  191.     textcolor(white);
  192.     gotoxy(30,19); writeln('Uscire ');
  193.     repeat
  194.     begin
  195.     tasto:=readkey;
  196.     if tasto=#13 then begin
  197.     registra;
  198.     stop:=true
  199.     end;
  200.     if tasto=#80 then begin cont:=cont+1; move:=true end;
  201.     if tasto=#72 then begin cont:=cont-1; move:=true end;
  202.     end;
  203.     until (tasto=#13) or (tasto=#80) or (tasto=#72) or stop;
  204.     end;
  205.  
  206. 3:    begin
  207.     clrscr;
  208.     gotoxy(1,1); writeln('Cosa vuoi fare?');
  209.     gotoxy(30,15); writeln('Ascoltare musica');
  210.     gotoxy(30,17); writeln('Registrare musica');
  211.     textcolor(red);
  212.     gotoxy(30,19); writeln('Uscire');
  213.     repeat
  214.     begin
  215.         tasto:=readkey;
  216.         if tasto=#13 then
  217.             begin
  218.             writeln('Bye bye '); delay(3000);    
  219.             flag:=true
  220.             end;
  221.         if tasto=#80 then begin cont:=cont+1; move:=true end;
  222.         if tasto=#72 then begin cont:=cont-1; move:=true end;
  223.     end;
  224.     until (tasto=#13) or (tasto=#80) or (tasto=#72);
  225.     end;
  226. end;
  227.  
  228. until flag OR stop;
  229. end;
  230.  
  231.  
  232.  
  233. {Programma}
  234. begin
  235.  
  236. repeat
  237. menu
  238. until flag;
  239.  
  240. end.


Ultima modifica effettuata da Poggi Marco il 09/03/2010 alle 18:42
PM Quote