program project1;
uses
Crt;
procedure WriteText(X, Y, C: Byte; const S: string);
begin
GotoXY(X, Y);
TextColor(C);
WriteLn(S);
end;
procedure About;
begin
ClrScr;
WriteText(1, 1, 3, 'This is a demo showing how to do menu in console mode');
WriteText(1, 2, 3, 'in Pascal using Lazarus/FPC.');
repeat until KeyPressed;
ReadKey;
end;
procedure Quote;
begin
ClrScr;
case Random(5) of
0: begin
WriteText(1, 1, 2, '"The price of greatness is responsibility."');
WriteText(1, 2, 1, '(Sir Winston Churchill)');
end;
1: begin
WriteText(1, 1, 2, '"Whatever you are, be a good one"');
WriteText(1, 2, 1, '(Abraham Lincoln)');
end;
2: begin
WriteText(1, 1, 2, '"Everything you can imagine is real."');
WriteText(1, 2, 1, '(Pablo Picasso)');
end;
3: begin
WriteText(1, 1, 2, '"Never regret anything that made you smile."');
WriteText(1, 2, 1, '(Mark Twain)');
end;
4: begin
WriteText(1, 1, 2, '"Love is a serious mental disease."');
WriteText(1, 2, 1, '(Plato)');
end;
end;
repeat until KeyPressed;
ReadKey;
end;
var
C: Char;
begin
repeat
ClrScr;
WriteText(1, 3, 4, 'What do you want to do?');
WriteText(3, 5, 3, '[a] - About this demo');
WriteText(3, 7, 3, '[b] - Random quote');
WriteText(3, 9, 3, '[q] - Quit');
WriteText(1, 11, 7, 'Please type [a], [b] or [q]:');
C := LowerCase(ReadKey);
case C of
'a': About;
'b': Quote;
end;
until C = 'q';
ClrScr;
WriteText(1, 1, 7, 'Goodbye ...');
end.