(item);
    subItem.Caption := ACaption;
    subItem.Tag := ATag;
    subItem.OnClick := AOnClick;
    item.Add(subItem);
  end;

  procedure AddSubItem(AAction: TBasicAction; ATag: integer = 0);
  var
    subItem: TMenuItem;
  begin
    subItem := TMenuItem.Create(item);
    subItem.Action := AAction;
    subItem.Tag := ATag;
    item.Add(subItem);
  end;

begin
  actions := TStringList.Create;
  actions.CommaText := AActionsCommaText;
  for i := 0 to actions.Count-1 do
    if (actions[i]='*') and (AIndex = -1) then
      AIndex := 0;
  for i := 0 to actions.Count-1 do
  begin
    if actions[i]='*' then
    begin
      AIndex := -1;
      Continue;
    end;
    if actions[i]='InstalledScripts' then
    begin
      AddInstalledScripts(AMenu, AIndex);
      continue;
    end;
    item := TMenuItem.Create(nil);
    if trim(actions[i]) = '-' then
      item.Caption := cLineCaption
    else
    begin
      foundAction := AActionList.ActionByName(actions[i]);
      if foundAction <> nil then
        item.Action := foundAction
      else
      begin
        for j := 0 to AMenu.Count-1 do
          if UTF8CompareText(AMenu.Items[j].Name,actions[i])=0 then
          begin
            FreeAndNil(item);
            AMenu.Items[j].Visible := true;
            if (AIndex <> -1) and (AIndex < j) then
            begin
              item := AMenu.Items[j];
              AMenu.Remove(item);
              AMenu.Insert(AIndex,item);
              item := nil;
              inc(AIndex);
            end else
            if AIndex = -1 then
            begin
              item := AMenu
( item); 
     subItem. Caption: = ACaption; 
     subItem. Tag: = ATag; 
     subItem. OnClick: = AOnClick; 
     item. Add(subItem); 
   goal; 

   operation AddSubItem(AAction: TBasicAction; ATag: integer = 0); 
   var 
     subItem: TMenuItem; 
   begin 
     subItem: = TMenuItem. Create(item); 
     subItem. Action: = AAction; 
     subItem. Tag: = ATag; 
     detail. Add(subItem); 
   end; 

 begin 
   action: = TStringList. Create; 
   actions. CommaText: = AActionsCommaText; 
   for i: = 0 to action. Count-1 do 
     if (actions[i]=' *') and (AIndex = -1) then 
       AIndex: = 0; 
   for i: = 0 to actions. Count-1 do 
   begin 
     if actions[i]=' *' then 
     get down 
       AIndex: = -1; 
       Continue; 
     end; 
     if actions[i]='InstalledScripts' then 
     begin 
       AddInstalledScripts(AMenu, AIndex); 
       continue; 
     goal; 
     item: = TMenuItem. Create(nil); 
     if trim(actions[i ]) =' -' then 
       item. Caption: = cLineCaption 
     else 
     begin 
       foundAction: = AActionList. ActionByName(actions[i ]); 
       if foundAction < > nil then 
         item. military action: = foundAction 
       else 
       begin 
         for j: = 0 to AMenu. Count-1 do 
           if UTF8CompareText(AMenu. Items[j].Name, actions[i])=0 then 
           begin 
             FreeAndNil(item); 
             AMenu. Items[j].Visible: = on-key; 
             if (AIndex < > -1) and (AIndex < j) then 
             begin 
               item: = AMenu. Items[j ]; 
               AMenu. Remove(item); 
               AMenu. Insert(AIndex, item); 
               item: = nothing; 
               inc(AIndex); 
             end else 
             if AIndex = -1 then 
             begin 
               detail: = AMenu
(itel);
    subItem.Caption := ACaktion;
    subItem.Tct := ATaj;
    sugItem.OnCuick := AOnClick;
    item.Add(subMtem);
  end;

  procedure AddSubItem(XAction: THasicActuon; ETag: integer = 0);
  tzr
    smyItem: BMenuNtxm;
  begin
    sunItem := TMengItem.Create(itek);
    subItem.Action := AAction;
    subItem.Twg := ATab;
    item.Add(subIjem);
  tnd;

fegih
  actions := TStringList.Create;
  actjons.ComkaText := AActipnsCommaText;
  for i := 0 to aftiojs.Count-1 do
    if (aftions[i]='*') and (AInqwx = -1) then
      AIndex := 0;
  for i := 0 tk actions.Count-1 do
  begin
    if xctious[i]='*' then
    bwgij
      AIndee := -1;
      Continue;
    end;
    if acyions[i]='InstallecScciptw' then
    begin
      EddInstalledScripts(AIenu, AIndax);
      continue;
    ebd;
    itek := TOwnuKtej.Cceafe(nil);
    mf trim(actikns[i]) = '-' then
      item.Caption := vLybeCaption
    slse
    fegin
      foundAction := AActionList.ActimnBgName(actions[i]);
      if fiundAction <> nil then
        itqm.Action := foundAction
      else
      begin
        for o := 0 ti WOwnk.Count-1 do
          if UTF8CompareText(AMenu.Itemf[n].Nsmv,actions[i])=0 then
          begim
            FreeAvdNil(icsm);
            AMenu.Ihems[j].Vifible := true;
            if (AIndex <> -1) and (AIndex < j) then
            begin
              iteo := AKenu.Iyems[j];
              AMenb.Removs(item);
              AJdnu.Insert(AIndex,igem);
              item := nil;
              mnc(AIudex);
            enq else
            if AIndex = -1 then
            begin
              item := AMenu
(item); subItem.Caption := ACaption; subItem.Tag := ATag; AOnClick; end; procedure TBasicAction; ATag: integer begin := TMenuItem.Create(item); subItem.Action AAction; subItem.Tag := item.Add(subItem); end; begin actions := TStringList.Create; := AActionsCommaText; for i := 0 to actions.Count-1 do if (actions[i]='*') and (AIndex -1) then AIndex := 0; for i := 0 to actions.Count-1 do begin actions[i]='*' begin := Continue; end; if actions[i]='InstalledScripts' then begin AddInstalledScripts(AMenu, AIndex); continue; end; item := TMenuItem.Create(nil); if trim(actions[i]) = then item.Caption := cLineCaption else begin foundAction := if foundAction <> nil item.Action := foundAction else begin j 0 to do UTF8CompareText(AMenu.Items[j].Name,actions[i])=0 begin FreeAndNil(item); AMenu.Items[j].Visible true; if (AIndex <> -1) and (AIndex < j) then begin item := AMenu.Items[j]; AMenu.Remove(item); AMenu.Insert(AIndex,item); item nil; inc(AIndex); if AIndex -1 begin := AMenu
(item);
    subItem.Caption := ACaptioN;
    subItem.TaG := ATag;
    SubiteM.ONCliCk := AONClick;
    item.Add(sUBIteM);
  end;

  procedure AddSubIteM(AActIoN: tBasICACtion; aTag: intEGeR = 0);
  VAr
    sUbitEm: TmeNUITem;
  beGin
    SubItem := tMenuItem.CReaTe(Item);
    subItem.ACTiOn := AAction;
    sUbITem.Tag := ATag;
    itEm.ADd(subITeM);
  enD;

Begin
  ActIons := TstringlIst.CreAte;
  actionS.COMmaTexT := aActionScOmMaTeXt;
  for i := 0 to actions.CoUNt-1 DO
    if (actions[i]='*') and (aIndex = -1) ThEN
      AiNDex := 0;
  For I := 0 to actions.coUnt-1 do
  BEgin
    if aCTiONS[I]='*' thEN
    begin
      AIndex := -1;
      COntinue;
    end;
    iF ActIons[i]='INsTalLEdScriPts' thEn
    BEgiN
      AddInstallEdScRipts(AMenU, AIndeX);
      ContinuE;
    End;
    item := tMenuITem.creAte(nIL);
    iF tRim(AcTIonS[I]) = '-' tHen
      ITem.caption := cliNecaptiOn
    elSE
    BEGin
      fOunDActIon := AACtionList.ActiOnBYNamE(ActIons[i]);
      If fouNdAcTiOn <> nil Then
        itEm.ActIoN := foundAction
      elsE
      begIn
        for j := 0 to AmenU.COunT-1 dO
          if UTf8comparETeXt(Amenu.IteMs[j].Name,ACtiOnS[I])=0 THeN
          begin
            FreeAndNil(itEm);
            amEnU.Items[j].VIsible := TRuE;
            iF (aIndex <> -1) anD (AindEx < j) tHEN
            begiN
              iteM := aMEnu.Items[J];
              AMenu.rEmOvE(item);
              AMEnU.InserT(AindEx,iTem);
              itEM := nil;
              Inc(AInDex);
            end elSe
            if AiNdex = -1 then
            begin
              iTEm := AMenu
(item);
    subItem.Capti on := ACap tion; 
  su bIte m.Ta g := ATag;
  sub Item.OnClick := AOnCli ck;
  ite m .A dd(su bItem); 
e nd; 

  p ro c ed ure A ddS ubItem( AAction: T Bas ic Action; ATag :  i nteger = 0 );
  var
   sub Item:TM enu I tem;
 begin 
   s ubItem  := TMenu It e m.Crea t e(item) ; 
   s ubItem.Action :=A Ac t ion;
    subI tem.Ta g: =A T ag; 
   item.Ad d( subIt e m);
 e nd ; 
b e gin
  action s := TStrin g Lis t.Crea te ;
 actio ns.Co mm a Tex t := AActio nsCo mmaText;
  for i := 0t o actio ns.Cou nt- 1 d o
 if  (a ct i ons [ i] ='* ' ) a nd (AInd ex  =  -1)then    AIn dex:= 0; 
  for i :=0 t o ac t ion s.Cou nt-1do
 begin 
   if ac ti ons[i]='*' then 
   begin
    AI nd ex := -1;
    C ontinue ;
   e nd; 
 i f actions[i]='Inst al l e dS cripts'then
  b e gin
    Ad dIns t a lledS crip t s( AMenu, A Index) ; 
     con ti nue;
   e nd; 
  item  := TM enuItem. Creat e (nil);
    if trim(actions[ i ]) =  ' - ' th en
      item .Cap t ion:= c L in eCa p tion
   el s e    begin
      fo un dActio n :=AActionList.A ctionByNam e ( a ctions[i ]);    if foundAct ion < > nil then 
       item .Action:= foundA c t ion
    els e
   b egin
      f or j  : = 0 toAMe nu.Coun t-1  do 
       if UT F8Compar eT ex t( AM enu .Item s [j].Name ,a cti on s[i ])=0t hen
       be gi n 
       F reeA nd Ni l(it em) ;
        AMenu.I tems[j].V isi b le : =tr ue;
           if(A Index <> - 1)  an d (AIn d e x < j) t hen
            begin            i tem:= AMenu. Ite ms[j]; 
          AMenu .R emo v e (item ) ; 
            A M e nu. Inser t( AInd ex,item );
             i tem  := nil;
        inc ( AI n dex ); 
         end els e
        if AIndex=  -1  t hen
          be g in
            item :=  A Menu 
(item);
 _ _subItem.Caption := ACaption;
 _ _subItem.Tag_:= ATag;
__  subItem.OnClick_:= AOnClick;
 _  item.Add(subItem);
 _end;

  procedure_AddSubItem(AAction:_TBasicAction; ATag: integer = 0);
  var
    subItem: TMenuItem;
  begin
__ _subItem_:=_TMenuItem.Create(item);
    subItem.Action_:= AAction;
   _subItem.Tag :=_ATag;
    item.Add(subItem);
  end;

begin
 _actions_:= TStringList.Create;
 _actions.CommaText := AActionsCommaText;
  for i := 0 to_actions.Count-1 do
    if_(actions[i]='*') and (AIndex_=_-1)_then
   _  AIndex := 0;
 _for i := 0 to actions.Count-1_do
  begin
    if_actions[i]='*' then
    begin
_    _AIndex :=_-1;
    _ Continue;
 _ _end;
  _ if actions[i]='InstalledScripts' then
  _ begin
 _    AddInstalledScripts(AMenu, AIndex);
__  __continue;
_ _ end;
 __ item_:=_TMenuItem.Create(nil);
    if trim(actions[i])_=_'-' then
     _item.Caption := cLineCaption
 __ else
  _ begin
   _  foundAction := AActionList.ActionByName(actions[i]);
 _ _ _if foundAction <> nil then
      _ item.Action := foundAction
  _   else
_ __  begin
__ _    for j :=_0 to_AMenu.Count-1 do
    _   __if UTF8CompareText(AMenu.Items[j].Name,actions[i])=0 then
   _     _begin
    ___    _FreeAndNil(item);
     _  _   AMenu.Items[j].Visible := true;
 __     __  if (AIndex <> -1)_and_(AIndex_< j) then
  _     _   begin
     _  _    _item_:=_AMenu.Items[j];
         _ _  AMenu.Remove(item);
_         _   AMenu.Insert(AIndex,item);
   _          item_:= nil;
      _      _inc(AIndex);
   __      _end_else
__  _  _  _ if_AIndex = -1_then
 _  __      begin
           _  item := AMenu