FOR eachMenu:
LIST
OF TajoMenu ← menus, eachMenu.rest
UNTIL eachMenu=
NIL
DO
AppendToPopUp:
PROC [r:
ROPE] ~ {
tail ← tail.rest ← LIST[r];
};
optionList: LIST OF ROPE ← LIST["Dummy"]; --The actual list of rope for this menu
tail: LIST OF ROPE ← optionList; --Always points to tail of optionList
popUp: PopUp;
nEntries: CARDINAL ← 0; --Will contain the number of entries exclusive to this menu
tempEntry: LIST OF TajoEntry ← eachMenu.first.options;
Count the number of entries
FOR eachEntry:
LIST
OF TajoEntry ← eachMenu.first.options, eachEntry.rest
UNTIL eachEntry=
NIL
DO
nEntries ← nEntries+1;
ENDLOOP;
Create the PopUp record
popUp ← NEW[PopUpRec[nMenus+nEntries+1]];
popUp.action[0] ← NIL;
Add the other menu titles to the PopUp menu to be presented for this TajoMenu
UNTIL Rope.Equal[ringTail.first, eachMenu.first.title]
DO
--Point ringTail at our title
ringTail ← ringTail.rest;
ENDLOOP;
FOR index:
CARDINAL
IN [1..nMenus]
DO
rope: ROPE;
ringTail ← ringTail.rest; --Set up title name
rope ← Rope.Cat[Rope.Substr[base: filler, len: (nMenus-index)*2], ringTail.first];
IF index=nMenus THEN rope ← Rope.Cat[rope, "-----------"];
popUp.action[index] ← ringTail.first;
AppendToPopUp[rope];
ENDLOOP;
Add the menu entries to the PopUp menu
FOR index:
CARDINAL
IN [1..nEntries]
DO
ref: REF ← IF tempEntry.first.action=NIL THEN tempEntry.first.rope ELSE tempEntry.first.action;
AppendToPopUp[tempEntry.first.rope];
popUp.action[nMenus+index] ← ref;
tempEntry ← tempEntry.rest;
ENDLOOP;
Install the popUp menu into the TajoSystem
popUp.list ← optionList.rest;
IF ~SymTab.Insert[ts.x, eachMenu.first.title, popUp] THEN ERROR DuplicateName[];
ENDLOOP;