using IwbZero.Expr; using IwbZero.ToolCommon.StringModel; namespace IwbZero.ExprFunctions.Functions { /// /// Sub字符串 /// public class FunSubStr:IIwbFunction { public string Invoke(ExprObject exprObj) { string text = ""; ExprObject child = exprObj.GetChild(0); if (child != null) { text = child.Expr; child = exprObj.GetChild(2); if (child != null) { int num = child.Expr.ValI(); int num2 = text.Length; string text2 = "L"; child = exprObj.GetChild(4); if (child != null) { num2 = child.Expr.ValI(); if (num2 == 0) { var text3 = child.Expr.ToUpper(); text2 = text3 == "R" ? "R" : "L"; } } var child2 = exprObj.GetChild(6); if (child2 != null) { text2 = child2.Expr.ToUpper(); } if (num < 0) { num = 0; } if (num < text.Length) { if (text2 == "R") { text = text.Substring(0, text.Length - num); if (child2 == null) { return text; } num = text.Length - num2; if (num < 0) { num = 0; } } if (num2 + num > text.Length) { num2 = text.Length - num; } text = text.Substring(num, num2); } else { text = ""; } } } return text; } } }