public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "CMDR_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix"); return(true); } cmdname = sp.NextWord(); } int cmdrid = EDCommander.CurrentCmdrID; if (cmdname != null && cmdname.Equals("CMDR", StringComparison.InvariantCultureIgnoreCase)) { string name = sp.NextQuotedWord() ?? "-----!"; EDCommander cmdr = EDCommander.GetCommander(name); if (cmdr != null) { cmdrid = cmdr.Nr; } else { ap.ReportError("Commander not found"); } cmdname = sp.NextWord(); } EDDiscoveryForm discoveryform = (ap.actioncontroller as ActionController).DiscoveryForm; List <EDCommander> cmdrlist = EDCommander.GetCommanders(); if (cmdname != null) { if (cmdname.Equals("LIST", StringComparison.InvariantCultureIgnoreCase)) { string wildcard = sp.NextQuotedWord() ?? "*"; int count = 1; foreach (var cmdr in cmdrlist) // only current commander ID considered { if (cmdr.Name.WildCardMatch(wildcard)) { DumpCMDR(ap, prefix + count++.ToStringInvariant() + "_", cmdr); } } ap[prefix + "MatchCount"] = (count - 1).ToStringInvariant(); ap[prefix + "TotalCount"] = cmdrlist.Count.ToStringInvariant(); } else if (cmdname.Equals("CHANGETO", StringComparison.InvariantCultureIgnoreCase)) { discoveryform.ChangeToCommander(cmdrid); // which will cause DIsplay to be called as some point } else { ap.ReportError("Unknown command"); } } else { ap.ReportError("Missing command"); } } else { ap.ReportError(res); } return(true); }