home *** CD-ROM | disk | FTP | other *** search
- unit menu;
-
- interface
- function menu1(x,y:integer;work_string:string):string;
- { work_string =
- 'opt1.opt2.opt3'
- }
- procedure box(x,y,xx,yy:integer);
-
- implementation
- uses crt;
-
- procedure box(x,y,xx,yy:integer);
- var i:integer;
- begin
- gotoxy(x,yy);write(chr(200));
- gotoxy(x,y);write(chr(201));
- gotoxy(xx,y);write(chr(187));
- gotoxy(xx,yy);write(chr(188));
- for i:=(x+1) to (xx-1) do begin
- gotoxy(i,y);
- write(chr(205));
- gotoxy(i,yy);
- write(chr(205));
- end;
-
- for i:=(y+1) to (yy-1) do begin
- gotoxy(x,i);
- write(chr(186));
- gotoxy(xx,i);
- write(chr(186));
- end;
- end;
-
- function menu1(x,y:integer;work_string:string):string;
- var
- choices:array[1..20] of string;
- i,ii:integer;
- pos_mark,num_choices,
- longest_one:integer;
- tmp_attr:integer;
- begin
- tmp_attr:=textattr;
- textattr:=7;
- ii:=1;
- choices[ii]:='';
- for i:=1 to length(work_string) do
- if work_string[i]<>',' then
- choices[ii]:=choices[ii]+work_string[i]
- else begin
- inc(ii);
- choices[ii]:='';
- end;
- inc(ii);
- choices[ii]:='';
-
- num_choices:=ii-1;
- longest_one:=0;
- for i:=1 to num_choices do
- if length(choices[i])>longest_one then
- longest_one:=length(choices[i]);
-
- box(x,y, x+longest_one+1, y+num_choices+1);
- for i:=1 to num_choices do begin
- gotoxy(x+1,y+i);
- write(choices[i]);
- end;
-
- {---------------------------}
- pos_mark:=1;
- gotoxy(x+1,y+pos_mark);
- textattr:=120;
- write(choices[pos_mark]);
-
- repeat
- i:=pos_mark;
-
- if ord(readkey)=13 then begin
- menu1:=choices[pos_mark];
- textattr:=tmp_attr;
- exit;
- end else
-
- case readkey of
- 'H':if pos_mark>1 then dec(pos_mark);
- 'P':if pos_mark<num_choices then inc(pos_mark);
- end;
-
- gotoxy(x+1,y+i);
- textattr:=7;
- write(choices[i]);
-
- gotoxy(x+1,y+pos_mark);
- textattr:=120;
- write(choices[pos_mark]);
- until false;
- end;
-
- end.