public void MakeLstPos() { if (pData == null) { return; } int tCol = 0; int row = 0; int col = 0; int pCol = 0; string aliesName = ""; LstPos = new List <clsPos>(); LstPos.Add(new clsPos()); resetPos(); while (true) { string data; char ch; //読みだすデータの頭出し if (aliesName == "") { if (pData.Count == row) { return; } data = pData[row].Txt; pCol = pData[row].Lp.col; } else { data = aData[aliesName].Txt; pCol = aData[aliesName].Lp.col; } //解析行の解析位置が終端に達したときの処理 while (data.Length == col + pCol) { if (aliesName == "") { row++; if (pData.Count == row) { break; } else { data = pData[row].Txt; pCol = pData[row].Lp.col; col = 0;// pData[row].Lp.col; clsPos p = new clsPos(); p.tCol = tCol; p.alies = ""; p.col = 0; p.row = row; LstPos.Add(p); break; } } else { clsPos p = stackPos.Pop(); aliesName = p.alies; col = p.col; row = p.row; if (aliesName == "") { data = pData[row].Txt; pCol = pData[row].Lp.col; } else { data = aData[aliesName].Txt; pCol = aData[aliesName].Lp.col; } p.tCol = tCol; LstPos.Add(p); } } ch = data[col + pCol]; //解析位置でエイリアス指定されている場合 while (ch == '%') { string a = getAliesName(data, col + pCol); if (a != "") { clsPos p = new clsPos(); p.alies = aliesName; p.col = col + a.Length + 1; p.row = row; stackPos.Push(p); data = aData[a].Txt; pCol = aData[a].Lp.col; col = 0; aliesName = a; row = 0; p = new clsPos(); p.tCol = tCol; p.alies = a; p.col = 0; p.row = 0; LstPos.Add(p); } else { msgBox.setWrnMsg(msg.get("E06000") , (aliesName == "") ? pData[row].Lp : aData[aliesName].Lp ); col++; } ch = data[col + pCol]; } tCol++; col++; //解析行の解析位置が終端に達したときの処理 while (data.Length == col + pCol) { if (aliesName == "") { row++; if (pData.Count == row) { break; } else { data = pData[row].Txt; pCol = pData[row].Lp.col; col = 0; clsPos p = new clsPos(); p.tCol = tCol; p.alies = ""; p.col = 0; p.row = row; LstPos.Add(p); break; } } else { clsPos p = stackPos.Pop(); aliesName = p.alies; col = p.col; row = p.row; if (aliesName == "") { data = pData[row].Txt; pCol = pData[row].Lp.col; } else { data = aData[aliesName].Txt; pCol = aData[aliesName].Lp.col; } p.tCol = tCol; LstPos.Add(p); } } } }
/// <summary> /// 解析位置を指定する /// </summary> /// <param name="tCol">解析位置</param> /// <remarks>エイリアスを毎回展開しながら位置を算出するためとても効率が悪い</remarks> public void setPos(int tCol) { if (pData == null) { return; } if (LstPos == null) { MakeLstPos(); } int i = 0; while (i != LstPos.Count && tCol >= LstPos[i].tCol) { i++; } pos.tCol = tCol; pos.alies = LstPos[i - 1].alies; pos.col = LstPos[i - 1].col + tCol - LstPos[i - 1].tCol; pos.row = LstPos[i - 1].row; //if (pos.alies == "" && pos.col >= pData[pos.row].Txt.Length - 1 && pos.row >= pData.Count - 1) //{ // dataEnd = true; //} return; dataEnd = false; int row = 0; int col = 0; int n = 0; string aliesName = ""; resetPos(); pos.tCol = tCol; while (true) { string data; char ch; //読みだすデータの頭出し if (aliesName == "") { if (pData.Count == row) { dataEnd = true; return; } data = pData[row].Txt; } else { data = aData[aliesName].Txt; } while (data.Length == col) { if (aliesName == "") { row++; if (pData.Count == row) { dataEnd = true; break; } else { data = pData[row].Txt; col = 0; break; } } else { clsPos p = stackPos.Pop(); aliesName = p.alies; col = p.col; row = p.row; if (aliesName == "") { data = pData[row].Txt; } else { data = aData[aliesName].Txt; } } } ch = data[col]; while (ch == '%') { string a = getAliesName(data, col); if (a != "") { clsPos p = new clsPos(); p.alies = aliesName; p.col = col + a.Length + 1; p.row = row; stackPos.Push(p); data = aData[a].Txt; col = 0; aliesName = a; row = 0; } else { msgBox.setWrnMsg("指定されたエイリアス名は定義されていません。" , (aliesName == "") ? pData[row].Fn : aData[aliesName].Fn , (aliesName == "") ? pData[row].Num : aData[aliesName].Num ); col++; } ch = data[col]; } if (n == tCol) { pos.row = row; pos.col = col; pos.alies = aliesName; break; } n++; col++; while (data.Length == col) { if (aliesName == "") { row++; if (pData.Count == row) { dataEnd = true; break; } else { data = pData[row].Txt; col = 0; break; } } else { clsPos p = stackPos.Pop(); aliesName = p.alies; col = p.col; row = p.row; if (aliesName == "") { data = pData[row].Txt; } else { data = aData[aliesName].Txt; } } } } }
/// <summary> /// パート情報をリセットする /// </summary> public void resetPos() { pos = new clsPos(); stackPos = new Stack <clsPos>(); }
//private List<clsPos> LstPos = null; //public int pcmMapNo { get; set; } = 0; //public int dutyCycle { get; set; } = 0; //public int oldDutyCycle { get; set; } = -1; //public int oldFreq { get; set; } = -1; //public bool directModeVib { get; set; } //public bool directModeTre { get; set; } //public int pitchBend { get; set; } = 0; //public int tieBend { get; set; } = 0; //public int portaBend { get; set; } = 0; //public int lfoBend { get; set; } = 0; //public int bendStartOctave { get; set; } = 0; //public char bendStartNote { get; set; } = 'c'; //public int bendStartShift { get; set; } = 0; //public int velocity { get; set; } = 110; //public int effectDistortionSwitch { get; internal set; } = 0; //public int effectDistortionVolume { get; internal set; } = 32; //public bool isOp4Mode { get; internal set; } = false; //public int beforeBendNoteNum { get; internal set; } = -1; //public int panRL { get; internal set; } //public int panRR { get; internal set; } //public int flag { get; internal set; } //public bool changeFlag { get; internal set; } //public int C352flag { get; internal set; } public void MakeLstPos(partPage page) { if (page.pData == null) { return; } int tCol = 0; int row = 0; int col = 0; int pCol = 0; string aliesName = ""; //int aliesDepth = 0; page.LstPos = new List <clsPos>(); page.LstPos.Add(new clsPos()); page.stackAliesPos = new Stack <LinePos>(); resetPos(page); while (true) { string data; char ch; //読みだすデータの頭出し if (aliesName == "") { if (page.pData.Count == row) { return; } data = page.pData[row].Txt; pCol = page.pData[row].Lp.col; } else { data = aData[aliesName].Txt; pCol = aData[aliesName].Lp.col; } data = Common.CutComment(data); //解析行の解析位置が終端に達したときの処理 while (data.Length == col + pCol) { if (aliesName == "") { row++; if (page.pData.Count == row) { break; } else { data = page.pData[row].Txt; data = Common.CutComment(data); pCol = page.pData[row].Lp.col; col = 0;// pData[row].Lp.col; clsPos p = new clsPos(); p.tCol = tCol; p.alies = null; p.col = 0; p.row = row; page.LstPos.Add(p); break; } } else { clsPos p = page.stackPos.Pop(); aliesName = p.alies[0].aliesName; page.stackAliesPos.Pop(); col = p.col; row = p.row; if (aliesName == "") { data = page.pData[row].Txt; pCol = page.pData[row].Lp.col; } else { data = aData[aliesName].Txt; pCol = aData[aliesName].Lp.col; } data = Common.CutComment(data); p.tCol = tCol; page.LstPos.Add(p); } } ch = data[col + pCol]; //解析位置でエイリアス指定されている場合 while (ch == '%') { string a = getAliesName(data, col + pCol); if (a != "") { LinePos ali = new LinePos(); ali.aliesName = aliesName; //現在のエイリアス名 ali.aliesNextName = a; //飛び先となるエイリアス名 ali.aliesDepth = page.stackAliesPos.Count + 1; //ali.nextDepth = page.stackAliesPos.Count + 1; ali.row = page.pData[row].Lp.row; ali.col = col + pCol; ali.length = a.Length + 1; //マクロから復帰する際に使用する場所情報を作成 clsPos p = new clsPos(); p.col = col + a.Length + 1; p.row = row; p.alies = CopyAndToArrayStackAliesPos(page.stackAliesPos); //現時点のスタックの内容に戻す page.stackPos.Push(p); page.stackAliesPos.Push(ali); data = aData[a].Txt; data = Common.CutComment(data); pCol = aData[a].Lp.col; col = 0; aliesName = a; row = 0; p = new clsPos(); p.tCol = tCol; p.alies = CopyAndToArrayStackAliesPos(page.stackAliesPos); p.col = 0; p.row = 0; page.LstPos.Add(p); } else { msgBox.setWrnMsg(msg.get("E06000") , (aliesName == "") ? page.pData[row].Lp : aData[aliesName].Lp ); col++; } ch = data[col + pCol]; } tCol++; col++; //解析行の解析位置が終端に達したときの処理 while (data.Length == col + pCol)// || data[col + pCol] == ';') { if (aliesName == "") { row++; if (page.pData.Count == row) { break; } else { data = page.pData[row].Txt; data = Common.CutComment(data); pCol = page.pData[row].Lp.col; col = 0; clsPos p = new clsPos(); p.tCol = tCol; p.alies = null; p.col = 0; p.row = row; page.LstPos.Add(p); break; } } else { clsPos p = page.stackPos.Pop(); aliesName = p.alies.Length < 1 ? "" : p.alies[0].aliesNextName; page.stackAliesPos.Pop(); col = p.col; row = p.row; if (aliesName == "") { data = page.pData[row].Txt; data = Common.CutComment(data); pCol = page.pData[row].Lp.col; } else { data = aData[aliesName].Txt; data = Common.CutComment(data); pCol = aData[aliesName].Lp.col; } p.tCol = tCol; page.LstPos.Add(p); } } } }