Getting Arguments in Extended Expression Functions

I was able to add a sample expression function by writing this class:

public class HelloFunction extends AbstractFunction {

	public HelloFunction() {
	}

	@Override
	public QualifiedValue execute(Expression[] args) throws ExpressionException {
		return new BasicQualifiedValue(String.format("Hello World %d", args.length));
	}

	@Override
	public String getArgDocString() {
		return "int";
	}

	@Override
	public Class<?> getType() {
		return String.class;
	}

	@Override
	protected String getFunctionDisplayName() {
		return "helloWorld";
	}
}

And adding this to my Designer hook:

	@Override
	public void configureFunctionFactory(ExpressionFunctionManager factory) {
		factory.getCategories().add("Extended");
		factory.addFunction("helloWorld", "Extended", new HelloFunction());
		super.configureFunctionFactory(factory);
	}

However, no amount of SDK and forum scouring will turn up the method for getting the argument passed in through expression.

I’m assuming it’s simple, that I am extending the wrong function class or misreading the Expression class, but how do I get the args?

I just figured this out. Simple as predicted:

	@Override
	public QualifiedValue execute(Expression[] exes) throws ExpressionException {
		Object value = exes[0].execute().getValue();
		return new BasicQualifiedValue(String.format("Hello World: %s", value.toString()));
	}

You call execute on the Expression(s) passed in, they return a QualifiedValue, you call getValue() on the QV(s).

Now you have the arg(s) from the Expression.

Glad you figured that out! Meant to answer this yesterday but got sidetracked by something.