Код: Выделить всё
uses crt;
type
TMenu = record Size : Byte;
Items : Array[1..25] of String[30];
ActColor : Byte;
InactColor : Byte;
end;
var
m : TMenu;
c : Integer;
Function GetMenuChoise(var m:TMenu):Integer;
var
mlen, x : Integer;
act, latr: Integer;
ch : Char;
begin
GetMenuChoise := -1;
if m.Size < 1 then exit;
mlen := 0;
for x := 1 to m.Size do
if Length(m.Items[x]) > mlen then mlen := length(m.Items[x]);
if mlen = 0 then exit;
latr := TextAttr;
inc(mlen, 2);
act := 1;
repeat
For x := 1 to m.Size do
begin
GotoXY(1, x);
if x = act then TextAttr := m.ActColor
else TextAttr := m.InactColor;
Write(m.Items[x] :( mlen-1),' ');
end;
ch := readkey;
If ch = #0 then
begin
ch := readkey;
if (ch = #72) and (act > 1) then dec(act);
if (ch = #80) and (act < m.Size) then inc(act);
end;
until (ch = #13) or (ch = #27);
TextAttr := latr;
if ch = #27 then act := -1;
GetMenuChoise := act;
end;
begin
m.Size := 4;
m.Items[1] := '1 - 1';
m.Items[2] := '2 - 2';
m.Items[3] := '3 - 3';
m.Items[4] := '4 - 4';
m.ActColor := $B4;
m.InactColor := $07;
ClrScr;
C := GetMenuChoise(m);
Writeln;
Writeln;
Writeln('You have selected ',C,' item');
end.
Не могу создать модуль с этой функцией...
Помогите плиззз...
Создайте плиззз модуль с этой функцией....