SubString.js 786 Bytes
Newer Older
wangcong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/**
 * 字符串截取函数
 * @author fengjiansheng
 * @date 2021-12-10
 */
export default {
    execute: function () {
        console.log("s1 SubString")
        if (arguments && arguments[0] && arguments[0].length >= 2 && arguments[0].length <= 3 && arguments[1]) {
            let s = arguments[0][0].getResult().Value
            let a;
            let b = 0;
            a = arguments[0][1].getResult().Value
            if (arguments[0].length === 3) {
                b = arguments[0][2].getResult().Value
            }
            if (arguments[0].length === 3) {
                return s.substring(a, b)
            } else {
                return s.substring(a)
            }
        }
    },
    getResultType: function () {
        return FMR.ConstDataTypes.Bool
    }
}