21/05/12 9:50
Goblin
La funzione MessaBox ha un ritorno (se apri la unit windows vedi i valori):
IDOK = 1; ID_OK = IDOK;
IDCANCEL = 2; ID_CANCEL = IDCANCEL;
IDABORT = 3; ID_ABORT = IDABORT;
IDRETRY = 4; ID_RETRY = IDRETRY;
IDIGNORE = 5; ID_IGNORE = IDIGNORE;
IDYES = 6; ID_YES = IDYES;
IDNO = 7; ID_NO = IDNO;
IDCLOSE = 8; ID_CLOSE = IDCLOSE;
IDHELP = 9; ID_HELP = IDHELP;
IDTRYAGAIN = 10;
IDCONTINUE = 11;
Dunque il tuo sorgente deve essere modificato
uses crt,windows;
begin
if MessageBox (50, 'bhkb jkn' , 'm', 100)=IDYES then
writeln('ciap')
else
writeln('saddd');
readkey;
end.
IDOK = 1; ID_OK = IDOK;
IDCANCEL = 2; ID_CANCEL = IDCANCEL;
IDABORT = 3; ID_ABORT = IDABORT;
IDRETRY = 4; ID_RETRY = IDRETRY;
IDIGNORE = 5; ID_IGNORE = IDIGNORE;
IDYES = 6; ID_YES = IDYES;
IDNO = 7; ID_NO = IDNO;
IDCLOSE = 8; ID_CLOSE = IDCLOSE;
IDHELP = 9; ID_HELP = IDHELP;
IDTRYAGAIN = 10;
IDCONTINUE = 11;
Dunque il tuo sorgente deve essere modificato
uses crt,windows;
begin
if MessageBox (50, 'bhkb jkn' , 'm', 100)=IDYES then
writeln('ciap')
else
writeln('saddd');
readkey;
end.
Ibis redibis non morieris in bello
21/05/12 11:59
mirco95
Goblin ti ringrazio di cuore.
Finche uso dei WriteLn va tutto ok pero se voglio fare una cosa del genere mi da errore :
Errore
Dopo questo vorrei fare un altra domanda.. Queste cose
IDOK = 1; ID_OK = IDOK;
IDCANCEL = 2; ID_CANCEL = IDCANCEL;
IDABORT = 3; ID_ABORT = IDABORT;
IDRETRY = 4; ID_RETRY = IDRETRY;
IDIGNORE = 5; ID_IGNORE = IDIGNORE;
IDYES = 6; ID_YES = IDYES;
IDNO = 7; ID_NO = IDNO;
IDCLOSE = 8; ID_CLOSE = IDCLOSE;
IDHELP = 9; ID_HELP = IDHELP;
IDTRYAGAIN = 10;
IDCONTINUE = 11;
a cosa servono..? So che sono domande molto furbe ahah ..
Grazie mille ancora
Edit:
Alla prima mio primo problema ho risolto.. Non avevo fatto caso al << ; >> che avevo messo ...
Edit2:
Ok sono riuscito a capire da solo a cosa servono. Grazie comunque
Finche uso dei WriteLn va tutto ok pero se voglio fare una cosa del genere mi da errore :
uses crt,windows,dos; begin if MessageBox (50, 'bhkb jkn' , 'm', 100)=IDYES then Exec('C:\Windows\system32\mspaint.exe','D:\Users\Mirco\Pictures\atlantis_by_flewdesigns-d4zdcgn.jpg'); else writeln('saddd'); readkey; end.
Errore
5 / 3 untitl~1.pas Fatal: Syntax error, ; expected but ELSE found
Dopo questo vorrei fare un altra domanda.. Queste cose
IDOK = 1; ID_OK = IDOK;
IDCANCEL = 2; ID_CANCEL = IDCANCEL;
IDABORT = 3; ID_ABORT = IDABORT;
IDRETRY = 4; ID_RETRY = IDRETRY;
IDIGNORE = 5; ID_IGNORE = IDIGNORE;
IDYES = 6; ID_YES = IDYES;
IDNO = 7; ID_NO = IDNO;
IDCLOSE = 8; ID_CLOSE = IDCLOSE;
IDHELP = 9; ID_HELP = IDHELP;
IDTRYAGAIN = 10;
IDCONTINUE = 11;
a cosa servono..? So che sono domande molto furbe ahah ..
Grazie mille ancora
Edit:
Alla prima mio primo problema ho risolto.. Non avevo fatto caso al << ; >> che avevo messo ...
Edit2:
Ok sono riuscito a capire da solo a cosa servono. Grazie comunque
Ultima modifica effettuata da mirco95 21/05/12 13:34
aaa
24/05/12 6:50
mirco95
Un altra informazione.
se io faccio il seguente codice:
Con il seguente codice mi da errore di compilazione dandomi errore il <<;>>.
Pur levando TUTTI gli <<;>> mi da sempre lo stesso errore.
Ho provato pure a creare per ogni richiesta un begin cioe;
Mi da sempre errore, grazie ancora
se io faccio il seguente codice:
uses crt,windows; begin writeln('attendere...'); delay(600); if MessageBox (50, 'bhkb jkn' , 'm', 100)=IDYES then Writeln('primo valore'); readln(a); writeln('secondo valore'); readln(b); c:=a+b; writeln('il totale e ',c); readkey; else Writeln('primo valore'); readln(a); writeln('secondo valore'); readln(b); c:=a-b; writeln('il totale e ',c); readkey; end.
Con il seguente codice mi da errore di compilazione dandomi errore il <<;>>.
Pur levando TUTTI gli <<;>> mi da sempre lo stesso errore.
Ho provato pure a creare per ogni richiesta un begin cioe;
Begin Writeln('primo valore'); readln(a); writeln('secondo valore'); readln(b); c:=a-b; writeln('il totale e ',c); readkey; end;
Mi da sempre errore, grazie ancora
aaa
24/05/12 11:47
Goblin
mmm qui mancano proprio le basi .....
allora
tutto il tuo programmino si può concentrare nella metà delle righe
1) Cerca di non duplicare il codice, il codice duplicato è frutto di bachi, e la sua manutenzione diventa difficile.
2) in pascal il costrutto if..then..else si forma così:
if <Condizione> then
begin
<Istruzione1>;
<Istruzione2>;
end
else
begin
<Istruzione3>;
<Istruzione4>;
end;
notare che dopo il primo "end" non c'e' il ";"
oppure
if <Condizione> then
<Istruzione2>
else
<Istruzione4>;
G.
allora
tutto il tuo programmino si può concentrare nella metà delle righe
uses crt,windows; var a,b,c: Integer; begin writeln('attendere...'); delay(600); Writeln('primo valore'); readln(a); writeln('secondo valore'); readln(b); if MessageBox (50, 'bhkb jkn' , 'm', 100)=IDYES then c:=a+b else c:=a-b; writeln('il totale e ',c); readkey; end.
1) Cerca di non duplicare il codice, il codice duplicato è frutto di bachi, e la sua manutenzione diventa difficile.
2) in pascal il costrutto if..then..else si forma così:
if <Condizione> then
begin
<Istruzione1>;
<Istruzione2>;
end
else
begin
<Istruzione3>;
<Istruzione4>;
end;
notare che dopo il primo "end" non c'e' il ";"
oppure
if <Condizione> then
<Istruzione2>
else
<Istruzione4>;
G.
Ibis redibis non morieris in bello