[Turn off line numbering]1: arg event, update_on, src; 2: var value, all; 3: 4: (> .perms(sender()) <); 5: if (!events) 6: events = #[]; 7: 8: // If/when more are added.. also update $help_sys_event_register 9: if (update_on != 'move && update_on != 'startup) 10: throw(~type, "Update on must be either 'move or 'startup"); 11: if (type(src) == 'symbol) { 12: if (src != 'location && src != 'this) 13: throw(~type, "Source types must be either 'location or 'this."); 14: } else if (type(src) != 'objnum) { 15: throw(~type, "Source type must be either a symbol or object."); 16: } else if (!src.is($event_handler)) { 17: throw(~type, "Source " + src.namef('ref) + " is not an event handler."); 18: } 19: if (events.contains(update_on)) { 20: all = events[update_on]; 21: if (events[update_on].contains(event)) { 22: value = replace(all[event], 2, src); 23: events = events.add(update_on, all.add(event, value)); 24: } else { 25: events = events.add(update_on, all.add(event, [0, src])); 26: } 27: } else { 28: events = events.add(update_on, #[[event, [0, src]]]); 29: }
// Created 17-Dec-1996 as a part of ColdCore, see: @help Credit