@@ -706,22 +706,22 @@ public override void ToString(StringBuilder stringBuilder, bool addBrackets)
706706 }
707707 }
708708
709- internal class Function_SUBSTRING : Function_N
709+ internal class Function_SUBSTRING : Function_3
710710 {
711- public Function_SUBSTRING ( FunctionBase [ ] funcs ) : base ( funcs )
711+ public Function_SUBSTRING ( FunctionBase func1 , FunctionBase func2 , FunctionBase func3 ) : base ( func1 , func2 , func3 )
712712 {
713713 }
714714
715715 public override Operand Calculate ( AlgorithmEngine work )
716716 {
717- var args1 = funcs [ 0 ] . Calculate ( work ) ; if ( args1 . Type != OperandType . TEXT ) { args1 = args1 . ToText ( "Function '{0}' parameter {1} is error!" , "Substring" , 1 ) ; if ( args1 . IsError ) { return args1 ; } }
718- var args2 = funcs [ 1 ] . Calculate ( work ) ; if ( args2 . Type != OperandType . NUMBER ) { args2 = args2 . ToNumber ( "Function '{0}' parameter {1} is error!" , "Substring" , 2 ) ; if ( args2 . IsError ) { return args2 ; } }
717+ var args1 = func1 . Calculate ( work ) ; if ( args1 . Type != OperandType . TEXT ) { args1 = args1 . ToText ( "Function '{0}' parameter {1} is error!" , "Substring" , 1 ) ; if ( args1 . IsError ) { return args1 ; } }
718+ var args2 = func2 . Calculate ( work ) ; if ( args2 . Type != OperandType . NUMBER ) { args2 = args2 . ToNumber ( "Function '{0}' parameter {1} is error!" , "Substring" , 2 ) ; if ( args2 . IsError ) { return args2 ; } }
719719
720720 var text = args1 . TextValue ;
721- if ( funcs . Length == 2 ) {
721+ if ( func3 == null ) {
722722 return Operand . Create ( text . AsSpan ( args2 . IntValue - work . ExcelIndex ) . ToString ( ) ) ;
723723 }
724- var args3 = funcs [ 2 ] . Calculate ( work ) ; if ( args3 . Type != OperandType . NUMBER ) { args3 = args3 . ToNumber ( "Function '{0}' parameter {1} is error!" , "Substring" , 3 ) ; if ( args3 . IsError ) { return args3 ; } }
724+ var args3 = func3 . Calculate ( work ) ; if ( args3 . Type != OperandType . NUMBER ) { args3 = args3 . ToNumber ( "Function '{0}' parameter {1} is error!" , "Substring" , 3 ) ; if ( args3 . IsError ) { return args3 ; } }
725725 return Operand . Create ( text . AsSpan ( args2 . IntValue - work . ExcelIndex , args3 . IntValue ) . ToString ( ) ) ;
726726 }
727727 public override void ToString ( StringBuilder stringBuilder , bool addBrackets )
0 commit comments