public static IVariable Add(ScalarString s, MetaList l, bool swap) { List <string> newList = new List <string>(); if (!swap) { newList.Add(s._string2); newList.AddRange(l.list); } else { newList.AddRange(l.list); newList.Add(s._string2); } return(new MetaList(newList)); }
public IVariable Indexer(GekkoTime t, bool isLhs, params IVariable[] indexes) { if (indexes.Length == 1) { IVariable index = indexes[0]; IVariable rv = null; if (this._string2 == Globals.indexerAloneCheatString) { //corresponds to empty indexer like ['fy*'], different from #a['fy*'] if (index.Type() == EVariableType.String) { //string vars = null; ExtractBankAndRestHelper h = Program.ExtractBankAndRest(((ScalarString)index)._string2, EExtrackBankAndRest.GetDatabank); List <string> output = Program.MatchWildcardInDatabank(h.name, h.databank); rv = new MetaList(output); } else { G.Writeln2("*** ERROR: The inside of a free-standing [...] list should not be a"); G.Writeln(" VAL, DATE or the like, for instance PRT [2.3] or PRT [2010q5]."); G.Writeln(" The right use is PRT [gd*] and similar."); throw new GekkoException(); } } else if (this._isName) { //#8932074324 //TODO: What about string 'jul05:fy' ?????? IVariable result = O.GetValFromStringIndexer(this._string2, index, 1, t); rv = result; } else { G.Writeln2("*** ERROR: You cannot use indexer on a string, for instance %s[2],"); G.Writeln(" but you may use the string as a name instead: {%s}[2015]."); throw new GekkoException(); } return(rv); } else { G.Writeln2("*** ERROR: Cannot use " + indexes.Length + "-dimensional indexer on STRING or NAME"); throw new GekkoException(); } }