VibeUK Posted February 6, 2020 Report post Posted February 6, 2020 (edited) Witam, Poczatki PASCAL'a, sporo rzeczy zrozumialem ale nie czaje skladni najwyrazniej. Const psw='pupa'; Var wpis:string; PROCEDURE Pytanie; Begin ClrScr; Writeln('I-------------------------------------------I'); Writeln('I PODAJ HASLO I'); Writeln('I I'); Writeln('I I'); Writeln('I-------------------------------------------I'); GotoXY(8,3); ReadLn(wpis) End; PROCEDURE Zle; Begin ClrScr; Writeln('I-------------------------------------------I'); Writeln('I ZLE HASLO!!! I'); Writeln('I ZLE HASLO!!! I'); Writeln('I ZLE HASLO!!! I'); Writeln('I-------------------------------------------I'); End; PROCEDURE Dobrze; Begin ClrScr; Writeln('I-------------------------------------------I'); Writeln('I I'); Writeln('I HASLO PRAWIDLOWE!!! I'); Writeln('I I'); Writeln('I-------------------------------------------I'); End; Begin REPEAT Pytanie; IF wpis=psw THEN Begin Dobrze; End; ELSE begin Zle; end; UNTIL wpis=psw; end. Dlaczego ELSE nie moze byc uzyte jak w przykladzie wyzej? Jak wykonac procedure Zle jesli wpisane haslo=/=pupa? Wiem, ze ten program mozna napisac inaczej ale chodzi mi wlasnie o uzycie ELSE. Dzieki I sorry za (pewnie glupie) pytanie :) Edited February 6, 2020 by VibeUK Quote Share this post Link to post Share on other sites More sharing options...
Małpożer Posted February 6, 2020 Report post Posted February 6, 2020 (edited) IF wpis=psw THEN Begin Dobrze; End; ELSE begin Zle; end; Nie powinno byc: if wpis = psw then Dobrze else Zle; ? ewentualnie IF wpis=psw THEN Begin Dobrze; End // to nie koneic instrukcji wiec nie wstawiasz srednika ELSE begin Zle; end; Edited February 6, 2020 by Małpożer Quote Share this post Link to post Share on other sites More sharing options...
VibeUK Posted February 6, 2020 Report post Posted February 6, 2020 Dokladnie, druga opcja jest ok, znalazlem 10 min temu w innym poradniku dla poczatkujacych. Begin REPEAT Pytanie; IF wpis=psw THEN Begin Dobrze; End Else begin Zle; end; UNTIL wpis=psw; end. ...kompiluje sie ok. Dzieki wielkie. Tematu nie zamykam bo pewnie za 2h znow cos wyskoczy ;) Quote Share this post Link to post Share on other sites More sharing options...