@Override
    public String execute(SampleResult previousResult, Sampler currentSampler)
            throws InvalidVariableException {
        JMeterVariables vars = getVariables();

        String stringToSplit = ((CompoundVariable) values[0]).execute();
        String varNamePrefix = ((CompoundVariable) values[1]).execute().trim();
        String splitString = ",";

        if (values.length > 2) { // Split string provided
            String newSplitString = ((CompoundVariable) values[2]).execute();
            splitString = newSplitString.length() > 0 ? newSplitString : splitString;
        }
        log.debug("Split {} using {} into {}", stringToSplit, splitString, varNamePrefix);
        String[] parts = JOrphanUtils.split(stringToSplit, splitString, "?");// $NON-NLS-1$

        vars.put(varNamePrefix, stringToSplit);
        vars.put(varNamePrefix + "_n", Integer.toString(parts.length));// $NON-NLS-1$
        for (int i = 1; i <= parts.length; i++) {
            if (log.isDebugEnabled()){
                log.debug(parts[i-1]);
            }
            vars.put(varNamePrefix + "_" + i, parts[i - 1]);// $NON-NLS-1$
        }
        vars.remove(varNamePrefix + "_" + (parts.length+1));
        return stringToSplit;

    }
@Test
    public void shouldSplitWithPreviousResultOnly() throws Exception {
        String src = "a,,c,";
        vars.put("VAR", src);
        SplitFunction split = splitParams("${VAR}", "VAR5", null);

        SampleResult previousResult = new SampleResult();
        previousResult.setResponseData("Some data", null);

        assertEquals(src, split.execute(previousResult, null));
        assertEquals("4", vars.get("VAR5_n"));
        assertEquals("a", vars.get("VAR5_1"));
        assertEquals("?", vars.get("VAR5_2"));
        assertEquals("c", vars.get("VAR5_3"));
        assertEquals("?", vars.get("VAR5_4"));
        assertNull(vars.get("VAR5_5"));
    }