/** SSDemo1s share the highest Score among their connected group. */ element SSDemo1 { // Typedefs typedef Unsigned(8) Score; // Utilities EventWindow ew; Random random; DebugUtils du; // Data members Score val; Void behave() { if (val == 0) // randomize initial vals val = random.bits(val.sizeof); WindowServices ws; // Scanning support SelectorServices ss; // Selection support ws.reset(1,4); // Scan all but us (for this example) ss.reset(); for (Int idx = ws.next(); idx >= 0; idx = ws.next()) { Atom a = ew[idx]; if (a as SSDemo1) ss.maximize(idx, (Int) a.val); } // This code is fairly general, but cumbersome. Compare SSDemo2 if (ss.selectionMade()) { Int sidx = ss.getSelectedKey(); // The site that maximized SSDemo1 f = (SSDemo1) ew[sidx]; // which we know is a SSDemo1 if (f.val > 0) // ..if they've been initted val = f.val; // ..pick up their val du.printContext(); // and report for debugging. } } }