Hi,

I'm trying to import a set of menus from a TextFile in the form of:

[MnuItem-0]
   Name=&File
   TearOffName=POP1
   Command=POP1
   Visibility=12
[MnuItem-1]
   Name=&New...    Ctrl+N
   Command=new
   HelpString=Creates a new file:  NEW
   Visibility=159
   SubLevel=1
[MnuItem-2]
   Name=&Open...    Ctrl+O
   TearOffName=POP3
   Command=open
   HelpString=Opens an existing file:  OPEN
   Visibility=159
   SubLevel=1
...............
...............


My code is as follows
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var allMenus:array[0..600]of TMenuItem;

procedure constructMenus;
var
 i,Level:integer;
 MenuTree:array[0..15]of integer;
 menulist:TstringList;
 TF:TextFile;
 ILine:string;
 SearchCharacter:PChar;
begin
 if FileExists(ExecPath+'menu.mnu')then
 begin
   AssignFile(TF,ExecPath+'menu.mnu');
   Reset(TF);
   i:=-1;
   menuList:=TStringList.Create;
   while not eof(TF)do
   begin
     Readln(TF,ILine);
     SearchCharacter:=StrScan(PChar(ILine),'[');
     if SearchCharacter<>nil then
     begin
       if SearchCharacter[0]='['then
       begin
         if menuList.Count>1 then
         begin
           inc(i);
           if menuList.Values['SubLevel']='' then Level:=0
           else Level:=strtoint(menuList.Values['SubLevel']);
           if Level=0 then
           begin
             allMenus[i]:=TMenuItem.Create(Form1.MainMenu1);
             allMenus[i].Caption:=menuList.Values['Name'];
             Form1.MainMenu1.Items.Add(allMenus[i]);
             MenuTree[0]:=i;
           end
           else
           begin
             allMenus[i]:=tmenuitem.create(allmenus[MenuTree[Level-1]]);
             allMenus[i].Caption:=menuList.Values['Name'];
             allMenus[i].Caption:=menuList.Values['HelpString'];
             allMenus[i].OnClick:=Form1.MenuItem2Click;
             allmenus[MenuTree[Level-1]].Add(allMenus[i]);
             MenuTree[Level]:=i;
           end;
         end;
         menuList.Clear
       end
       else menuList.Add(ILine);
     end
     else menuList.Add(ILine);
   end;
   menuList.Free;
   CloseFile(TF);
 end;
end; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I'd like help on 2 linked problems: Firstly my App halts at "allMenus[i].OnClick:=Form1.MenuItem2Click;" with the error "Wrong Number of parameters specified."

Procedure MenuItem2Click is in Unit2 and is in the form "procedure TForm1.MenuItem2Click(Sender: TObject);" I understand, from Googling extensively, that this should work.

And secondly, how can I access the Command=new Name/Value pair once it does get to MenuItem2Click.....

I hope this is reasonably clear.

--
Dave Coventry
Tel:  +27(0)31 3092301
Fax:  +27(0)31 3092301
Cell: +27(0)82 3685983

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to