| 2885 | } |
| 2886 | |
| 2887 | String substring(String s) { |
| 2888 | s = getStringFunctionArg(s); |
| 2889 | int index1 = (int)interp.getExpression(); |
| 2890 | int index2 = s.length(); |
| 2891 | if (interp.nextToken()==',') |
| 2892 | index2 = (int)getLastArg(); |
| 2893 | else |
| 2894 | interp.getRightParen(); |
| 2895 | if (index1>index2) |
| 2896 | interp.error("beginIndex>endIndex"); |
| 2897 | checkIndex(index1, 0, s.length()); |
| 2898 | checkIndex(index2, 0, s.length()); |
| 2899 | return s.substring(index1, index2); |
| 2900 | } |
| 2901 | |
| 2902 | private String getStringFunctionArg(String s) { |
| 2903 | if (s==null) { |