internal void AddMacro(CMacro x) { if (m_htbl.ContainsKey(x.Name)) { m_htbl[x.Name] = x; } else { m_htbl.Add(x.Name, x); } }
internal string Rename(string oldname, string newname) { newname = newname.Replace(' ', '_'); if (m_htbl.ContainsKey(newname)) { return(newname); } CMacro m = (CMacro)m_htbl[oldname]; m.Name = newname; m_htbl.Remove(oldname); m_htbl.Add(newname, m); return(newname); }
internal CMacroFile(string fn) { try { StreamReader sr = new StreamReader(fn); string ln = sr.ReadLine(); if (ln != "MPUlt Macro File") { goto _1; } FileName = fn; ln = sr.ReadLine(); string[] ss = ln.Split(' '); Puzz = ss[0]; dim = int.Parse(ss[1]); int nm = int.Parse(ss[2]); m_htbl = new Hashtable(); for (int i = 0; i < nm; i++) { ln = sr.ReadLine(); ss = ln.Split(' '); string name = ss[0]; int nstk = int.Parse(ss[1]); int lm = int.Parse(ss[2]); int[] stks = new int[nstk]; for (int j = 0; j < nstk; j++) { stks[j] = int.Parse(ss[j + 3]); } double[] pt = null; if (dim == 4) { ss = sr.ReadLine().Split(' '); pt = new double[dim]; for (int j = 0; j < dim; j++) { pt[j] = double.Parse(ss[j], CultureInfo.InvariantCulture); } } long[] code = new long[lm]; int p = 0; while (p < lm) { ln = sr.ReadLine(); ss = ln.Split(' '); for (int j = 0; j < ss.Length; j++) { if (p == lm) { break; } if (ss[j] != "") { code[p++] = long.Parse(ss[j]); } } } CMacro mm = new CMacro(name, nstk, stks, pt, lm, code); m_htbl.Add(name, mm); } sr.Close(); return; } catch { } _1: m_htbl = new Hashtable(); FileName = null; Puzz = "3^4"; dim = 4; }