public int readElement(ArrayList array, int scroll) { bool reachEnd = false; bool error = false; while (true) { String s = (String)array[scroll]; if (s.StartsWith("#defineEnd")) { reachEnd = true; } else { String [] sSeperate = s.Trim().Split(' '); int equalsID = -1; for (int i = 0; i < sSeperate.Length; i++) { if (sSeperate[i].Equals("=")) { equalsID = i; break; } } if (equalsID <= 0 || equalsID + 1 >= sSeperate.Length) { error = true; } else { String name = sSeperate[equalsID - 1]; String vlue = sSeperate[equalsID + 1]; vlue = vlue.Replace(";", ""); int intValue = form.convertStrToInt(vlue, scroll); if (!addElement(name, intValue)) { error = true; } } } if (error) { form.showString("【错误】发生在行:" + (scroll + 1)); scroll = array.Count; break; } scroll++; if (scroll >= array.Count || reachEnd) { break; } } return(scroll); }
public int readElement(ArrayList array, int scroll) { if (scroll < 0 || scroll >= array.Count) { scroll = array.Count; return(scroll); } bool reachElementEnd = false; bool error = false; String s = null; String [] sSeperate = null; while (true) { s = (String)array[scroll]; if (s.StartsWith("#map_ID:")) { s = s.Trim().Replace("#map_ID:", ""); sSeperate = s.Split(','); if (sSeperate != null && sSeperate.Length >= 2) { mapStart = form.convertStrToInt(sSeperate[0], scroll); mapEnd = form.convertStrToInt(sSeperate[1], scroll); } else { form.showString("【错误】MAP ID长度应该==2"); error = true; } } else if (s.StartsWith("#scene_ad_ID:")) { s = s.Trim().Replace("#scene_ad_ID:", ""); sSeperate = s.Split(','); for (int i = 0; i < sSeperate.Length; i++) { if (sSeperate[i].Equals("")) { continue; } int data = form.varList.getVarElement(sSeperate[i]); if (data < 0) { form.showString("【错误】未能找到定义的参数:" + (sSeperate[i])); error = true; break; } scene_ad_IDList.Add(data); } } else if (s.StartsWith("#scene_tp_ID:")) { s = s.Trim().Replace("#scene_tp_ID:", ""); sSeperate = s.Split(','); for (int i = 0; i < sSeperate.Length; i++) { if (sSeperate[i].Equals("")) { continue; } int data = form.convertStrToInt(sSeperate[i], scroll); if (data < 0) { form.showString("【错误】未能找到定义的参数:" + (sSeperate[i])); error = true; break; } scene_ad_IDList.Add(data); } } else if (s.StartsWith("#pic_name:")) { s = s.Trim().Replace("#scene_tp_ID:", ""); sSeperate = s.Split(','); for (int i = 0; i < sSeperate.Length; i++) { if (sSeperate[i] == null || sSeperate[i].Equals("")) { continue; } scene_ad_IDList.Add(sSeperate[i]); } } else if (s.Trim().Equals("#packEnd")) { reachElementEnd = true; } else if (s.Trim().Equals("")) { } else { error = true; } if (error) { form.showString("【错误】发生在行:" + (scroll + 1)); scroll = array.Count; break; } scroll++; if (scroll >= array.Count || reachElementEnd) { break; } } return(scroll); }