| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using IwbZero.Expr;
- using IwbZero.ToolCommon.StringModel;
- namespace IwbZero.ExprFunctions.Functions
- {
- /// <summary>
- /// Sub字符串
- /// </summary>
- 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;
- }
- }
- }
|