Помогите решить задачу...

За вознаграждение или нахаляву (если повезёт)

Модераторы: Хыиуду, MOTOCoder, Medved, dr.Jekill

Ответить
Anton_XXX
Сообщения: 108
Зарегистрирован: 21 дек 2006, 17:15

Привет все! У меня маленькая проблема с этой функцией:

Код: Выделить всё


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.

Не могу создать модуль с этой функцией...
Помогите плиззз...

Создайте плиззз модуль с этой функцией....
BBB
Сообщения: 1298
Зарегистрирован: 27 дек 2005, 13:37

ВАЖНО!!!
Имя файла обязательно должно быть GetMCh.pas. Т.е. точно так же, как название модуля (строка Unit GetMCh). Если хочешь другое имя файла, измени соответственно и эту строку исходного текста тоже.

Код: Выделить всё

Unit GetMCh;

Interface

type
TMenu = record     Size : Byte;
                  Items : Array[1..25] of String[30];
               ActColor : Byte;
             InactColor : Byte;
        end;

Function GetMenuChoise (var m:TMenu):Integer;

Implementition

uses crt;

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;

end.
Anton_XXX
Сообщения: 108
Зарегистрирован: 21 дек 2006, 17:15

большое спасибо... но я уже сделал модуль... ))))
Ответить